Transforming, sorting, and grouping JSON documents in the command-line - jq tutorial

Опубликовано: 28 Май 2020
на канале: Szymon Stepniak
26,433
1.1k

In this video, I show you how to use the jq command-line to parse and transform a JSON response to the desired format. I use openlibrary.org Search API to get a complex JSON document (~3600 lines) using curl command for further parsing using jq. In the first step, we extract three fields for each document (title, author, publishing year) and then we continue transforming the JSON - we sort it, we limit the number of elements, and last but not least, we group elements by the author name.
This video is the first part of the new series where we are going to learn how to use jq to solve some practical and real-life problems. I hope you enjoy it! 😀

⏱️ Timestamps:
00:00 | Intro
00:30 | What we are going to learn?
01:10 | Calling openlibrary.org Search API with curl
02:23 | Using object/value iterator
02:51 | Transforming input JSON to the desired format
03:43 | Filtering null values with the select function
04:23 | Sorting an array by the specific field using sort_by(expr)
05:46 | Limiting the number of elements using limit(n;expr)
06:48 | Grouping elements by the specific field using group_by(expr)
09:22 | End screen

===========================================

➡️ jq project website
- https://stedolan.github.io/jq/

➡️ "Parsing JSON in command-line with jq: basic filters and functions (part 1)" blog post
- https://e.printstacktrace.blog/parsin...

☕️ BUY ME A COFFEE (thanks in advance! 😀)
- https://e.printstacktrace.blog/buy-me...

📧 JOIN MY NEWSLETTER
- https://e.printstacktrace.blog/newsle...

🔥 MORE JQ TUTORIAL VIDEOS & RESOURCES:
- jq tutorial playlist -    • jq tutorial  
- jq cookbook blog posts - https://e.printstacktrace.blog/jq-coo...

📷 CAMERA GEAR I USE:
- My camera - https://e.printstacktrace.blog/gear/c...
- 25mm f1.7 lens - https://e.printstacktrace.blog/gear/l...
- Microphone - https://e.printstacktrace.blog/gear/m...
- LED lights - https://e.printstacktrace.blog/gear/l...
- Check my full kit - https://kit.co/wololock/my-youtube-st...

🛠️ TOOLS & SERVICES I USE TO:
- design YouTube thumbnails (Canva) - https://e.printstacktrace.blog/canva?...
- improve my grammar skills (Grammarly) - https://e.printstacktrace.blog/gramma...
- develop mailing list (ConvertKit) - https://e.printstacktrace.blog/conver...
- listen to audiobooks (Audible, 30 days free trial) - https://e.printstacktrace.blog/audibl...
- read Kindle ebooks (Kindle Unlimited) - https://e.printstacktrace.blog/kindle...
- secure network connection with VPN (NordVPN) - https://e.printstacktrace.blog/nordvp...
- improve SEO on YouTube (VidIQ) - https://e.printstacktrace.blog/vidiq?...
- host WordPress websites (Bluehost) - https://e.printstacktrace.blog/blueho...

❤️ SUPPORT MY WORK
- Github Sponsors - https://github.com/sponsors/wololock
- Open Collective - https://opencollective.com/eprintstac...
- Other options - https://e.printstacktrace.blog/suppor...

👋 STAY IN TOUCH:
- Blog - https://e.printstacktrace.blog?utm_source=jq02
- Twitter -   / wololock  
- LinkedIn -   / szymon-st%c4%99pniak-9a0b1630  
- Github - https://github.com/wololock

✉️ CONTACT:
For all subscribers, please use this email: [email protected]
For business inquires only, please use this email: [email protected]

DISCLAIMER: Some of the links above are affiliate links. If you decide to click that link and subsequently make a purchase, I will get a small percentage from your purchase. Using the affiliate link does not affect the final price of the product. The commission I earn comes at no additional cost to you. Thank you for supporting my channel so I can continue to provide you with free content on a regular basis!

And remember - it's all about helping YOU to become a better software developer! Thanks!

#eprintstacktrace #szymonstepniak