jq tutorial: Beginners Guilde To Parsing JSON from the Command-Line (Part 1)

  Рет қаралды 58,744

Szymon Stepniak

Szymon Stepniak

Күн бұрын

Пікірлер: 114
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Hello! Let me know if you liked this unusual intro 😁 I have a few more ideas for future videos, but I would love to hear your feedback. Thanks! 🙏
@j_holtslander
@j_holtslander 4 жыл бұрын
Liked it
@viswagb
@viswagb 3 жыл бұрын
very cool
@fleurdevries3121
@fleurdevries3121 Жыл бұрын
it helped me a lot without loosing much time. The way how you recorded it, was also entertaining. I am interested in a video if you can filter the API or more videos with examples on filtering with jq. Dziekuje bardzo!
@szymonstepniak
@szymonstepniak Жыл бұрын
@@fleurdevries3121 Thanks for your kind words and sharing your ideas! Take care, and have a good day!
@jsaenzMusic
@jsaenzMusic Жыл бұрын
So "artistically" and for entertainment, outstanding (the intro). But for wanting to get to the content to "grab" what I was looking for, may cause frustration. Although, I was in that boat and did not get frustrated because I liked the intro and the quality of the footage REALLY stood out! So....take it for what its worth. 😅
@jsaenzMusic
@jsaenzMusic Жыл бұрын
OMG thank you! I've been digging around the jq manual and other "searches" to find out how to return only the objects I want from the output!
@szymonstepniak
@szymonstepniak 11 ай бұрын
Glad I could help! Take care, and have a good day!
@HarshDeep61034
@HarshDeep61034 Жыл бұрын
Love the intro and story telling ❤ And off course the video is on point
@szymonstepniak
@szymonstepniak Жыл бұрын
Thank you so much!! Take care, and hava a good day!
@HarshDeep61034
@HarshDeep61034 Жыл бұрын
@@szymonstepniak you too ❤️
@nuriaarlandishernandez5168
@nuriaarlandishernandez5168 3 жыл бұрын
Just learned about json and I was having trouble understanding how it works untill I saw your video. Thank you very much!
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Glad it helped you, Nuria! I plan to create a few more videos on jq in the near future. Stay tuned, and have a good day!
@TomS-g2p
@TomS-g2p Жыл бұрын
Pierwsza "scena" cudo!! Fantasyczne wyjaśnienie, proste i do sedna. W 5 minut miałem rozwiązanie. Dzięki!!!
@szymonstepniak
@szymonstepniak Жыл бұрын
Dzięki wielkie za ciepłe słowa! Zawsze miło usłyszeć, że krótkie video pozwoliło zaoszczędzić sporo czasu :)
@mmu99
@mmu99 2 жыл бұрын
I saw jq when trying to debug jenkins console output and this video explained it well and concise. Thank you 🙂
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thanks for your kind words! Take care, and have a good day!
@MrSuriyam
@MrSuriyam 5 ай бұрын
Thank you 🙏 for putting together a wonderful training and easy to understand. Appreciate your time sir.
@szymonstepniak
@szymonstepniak 3 ай бұрын
Thank you!
@michaelbanzato6246
@michaelbanzato6246 2 жыл бұрын
Ow I spent some time on search... but this video safe my life. Thanks!
@szymonstepniak
@szymonstepniak 2 жыл бұрын
I'm happy to hear you found this video helpful 😉 Take care, and have a good day!
@manuelajannusch8208
@manuelajannusch8208 2 жыл бұрын
Mesej yang jelas, struktur yang jelas, mudah difahami, terima kasih
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thank you!
@rafaotetra
@rafaotetra 2 жыл бұрын
I really liked your methodology, practical and useful for daily tasks, it's usually all I need to do. Greetings from Brazil!
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thank you for your kind words, Rafael! Take care, and have a good day!
@СержХолодилов-ж7ь
@СержХолодилов-ж7ь 2 жыл бұрын
「あなたのコンテンツはとても感動的です」、
@giaotran2018
@giaotran2018 2 жыл бұрын
Nice! Very straight to the point. Easy to follow. Great intro to jq. Thanks!
@szymonstepniak
@szymonstepniak 2 жыл бұрын
I'm glad to hear you found this video useful, Giao! Take care, and have a good day!
@buf0rd
@buf0rd 2 жыл бұрын
Great video. Straight to the point!
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Glad to hear that! Take care, and have a good day!
@Megalcristo2
@Megalcristo2 2 жыл бұрын
I recommend ijq as an interactive jq. Not only you get the output as you type, but it has autocompletion, so you don't have to study the input beforehand that much.
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thanks for sharing ijq in the comment - I haven't heard about it before. I'm gonna try it out the next time :) Take care, and have a good day!
@1bigslug
@1bigslug 3 жыл бұрын
This was very easy to understand. Also I did what you did in the beginning as well. Thank you!
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Glad it helped! Have a good day!
@michaeldsouza7591
@michaeldsouza7591 2 жыл бұрын
JSON document I used in the video the link does not work anymore
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Yes, Github has shutdown the Jobs API some time after publishing this video.
@CaimAstraea
@CaimAstraea 3 жыл бұрын
How can I pick one single item from a list ? :/ Really scratching my head around this. Such a powerful tool surely must have a method to do it ?
@szymonstepniak
@szymonstepniak 3 жыл бұрын
It depends which element you want to pick from the list. You can use '.[n]' operator, where n is the index number. (E.g. "echo '[1,2,3,4]' | jq '.[0]'" => 1) Hope it helps. Take care, and have a good day!
@mlnw193
@mlnw193 3 жыл бұрын
Good evening sir, thank you for the knowledge. I want to ask, I have a log file that needs to be parsed and displayed, how to do it with jq? because the file extension is log not json
@szymonstepniak
@szymonstepniak 3 жыл бұрын
I'm not sure how to help you, Muhaammad. Log files usually consist of a different format than the JSON one. However, if your log file is a file that contains only valid JSON objects one under another, then you should be able to use it as an input for a jq (I haven't done anything like this, so I'm just guessing here.) But if your log file is not a valid JSON document (or documents), then there is nothing you can do.
@mlnw193
@mlnw193 3 жыл бұрын
@@szymonstepniak thanks for helping, I'm done with my case. I shouldn't have to pay attention to the file extension, because the contents are already json and can be parsed
@teengohan.ssj223
@teengohan.ssj223 2 жыл бұрын
God bless u sir. Thank you very much
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thank you for your kind words!
@davidkuda7074
@davidkuda7074 3 жыл бұрын
That's an excellent video, thanks.
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thank you so much for your kind words! Take care, and have a good day!
@RamkrishanYT
@RamkrishanYT 3 жыл бұрын
I use jq for a cli based random information generator but I wanna filter the data more so this video was very helpful
@szymonstepniak
@szymonstepniak 3 жыл бұрын
I'm glad to hear that the video was helpful, Ram! Take care, and have a good day!
@dm.vortex4171
@dm.vortex4171 4 жыл бұрын
So cool, this is best tool, better JOLT written on JAVA. For parsing any data source and resolve to change format this is fast and easy. Thank you for video!
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks a lot! I haven't heard about this JOLT, thanks for sharing the information. I will take a look at it out of curiosity, but I assume it cannot compete, as you mentioned, with the jq very well :) Good luck and happy hacking!
@dm.vortex4171
@dm.vortex4171 4 жыл бұрын
​Szymon Stepniak, There is similar technology like this jmespath.org/specification.html too
@horizonlimit89
@horizonlimit89 4 жыл бұрын
yes more of jq content would be nice.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks Shitiz, more jq videos soon :)
@tldc
@tldc 2 жыл бұрын
Loved the way you took us step by step starting from simple steps. Felt like having solved the problem with you live! 👏
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thanks for your kind words! Take care, and have a good day!
@j_holtslander
@j_holtslander 4 жыл бұрын
I wish this video helped me but duplicating everything I saw only resulted in” Cannot index array with string name “X” no matter what I tried.
@j_holtslander
@j_holtslander 4 жыл бұрын
Solved. I needed .[] to be .data[]
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Hi, Jay! Happy to hear you've figured it out. Have a good day!
@Forky218
@Forky218 Жыл бұрын
@@j_holtslander I need it also, but can you explain why? Thank you in advance!
@ravikumarhr4524
@ravikumarhr4524 4 жыл бұрын
Very informative thanks for the video 😊
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Glad it was helpful! There are two more jq related videos, here is the full playlist - kzbin.info/www/bejne/fITRkGZunKmpsK8 Have a good day!
@matthiasdebernardini3388
@matthiasdebernardini3388 3 жыл бұрын
Is jq faster than doing the same with a python script?
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Hi Matthias! I think speed in this case is the least important thing you should focus on. If you are a Python developer and you already have a script that consumes some JSON and extracts interesting information, writing another such a script is a better choice. If you don't know Python and you don't want to install a general purpose programming language to do some JSON document transformations, jq is the tool that is designed just for this purpose (and it is a single binary program with no dependencies.) I would assume jq to be a bit faster in this specific scope when compared to Python, but I wouldn't use it as a main argument for or against. Do you have other concerns I didn't have a chance to see? Thanks in advance and have a good day!
@matthiasdebernardini3388
@matthiasdebernardini3388 3 жыл бұрын
@@szymonstepniak hello! Well one thing I just found out is that jq can output csv with ‘@csv’ and I was wondering if you knew whether this was faster or slower. Like you said it doesn’t matter, I was already using jq to explore the data object so I ended up using it to clean the data and help me get it into a pandas data frame. It’s one line of code, compared to several for python. Cheers.
@alexandrutudosan3319
@alexandrutudosan3319 3 жыл бұрын
great tutorial
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thank you so much for your kind words, Alexandru! Take care, and have a good day!
@mohammadrezabooshehri6621
@mohammadrezabooshehri6621 3 жыл бұрын
Thanks, it was very useful. please share the reference which you've learned jq with us.
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thanks for your kind words, Mohammadreza! I learned jq by solving typical problems - I needed this tool in my Jenkins pipelines, I had specific requirements, and I just used the official manual to find a way how to met them stedolan.github.io/jq/manual/ Also, StackOverflow is a nice repository of use cases with interesting solutions that may help you learn even more about jq stackoverflow.com/questions/tagged/jq Happy learning and good luck!
@niteshsinghal88
@niteshsinghal88 2 жыл бұрын
Thanks for all of your videos, they are so impressive..! We are using a Global CI/CD pipeline in our environment for multiple application deployments. Can you please make a video on that using Jenkins groovy scripts? or please let me know if you have already created something similar already.
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thanks for your kind words! I can't promise anything - I haven't used Jenkins for more than a year, and I don't know if I will have enough time to re-invest into producing Jenkins-related content. We will see what the future brings :) Take care, and have a good day!
@niteshsinghal88
@niteshsinghal88 2 жыл бұрын
@@szymonstepniak sure thank you..! Waiting for your next video post :)
@tommynotts1400
@tommynotts1400 4 жыл бұрын
Very useful. Thank you.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thank you, Thomas, for the comment! I'm glad to hear this video was useful.
@testexample2729
@testexample2729 4 жыл бұрын
Very informative your videos. Thanks a lot. Keep it up.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks! You are very kind.
@hoannguyen2219
@hoannguyen2219 2 жыл бұрын
You try to give the video more brightness it will be great if you do
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thanks for the suggestion, Hoan! Take care, and have a good day!
@Bodybuilder900ml
@Bodybuilder900ml Жыл бұрын
Thank you sir!
@szymonstepniak
@szymonstepniak Жыл бұрын
You are welcome!
@georgechacko4276
@georgechacko4276 3 жыл бұрын
Very helpful thanks.
@szymonstepniak
@szymonstepniak 3 жыл бұрын
You're welcome! Take care and have a good day!
@toanvo618
@toanvo618 3 жыл бұрын
The video sound is pretty good, beyond my imagination
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thanks for your kind words, Toan! Take care, and have a good day!
@anuragpugalia6774
@anuragpugalia6774 4 жыл бұрын
this is really very helpful, i was looking for something really similar. Thanks, looking forward for your next video's. I have 1 query though, in you above example how would you get the top 3 records?
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Hi, Anurag! If your curl response returns a JSON array and you want to limit the number of objects to e.g. 3, you can use jq's limit function. For instance, the curl command from the video (jobs.github.com/positions.json?description=java) returns 50 objects. If I want to get only the first 3 of them in an array, I can do: curl -s "jobs.github.com/positions.json?description=java" | jq '[limit(3; .[])]' And now I get the array of three first JSON objects instead of the original response returning 50 objects.
@anuragpugalia8462
@anuragpugalia8462 4 жыл бұрын
​@@szymonstepniak ok . what am trying to achieve is, curl -s "jobs.github.com/positions.json?description=java" | jq '.[] | select(.type=="Full Time")' this will return me more than 1 result, so I want to add limit to the end result .. something like curl -s "jobs.github.com/positions.json?description=java" | jq '.[] | select(.type=="Full Time") | limit(3)' but this isn't working
@szymonstepniak
@szymonstepniak 4 жыл бұрын
@@anuragpugalia8462 To make the limit function work, you need to construct the array of objects first. Take a look at the output of the following command: jq '.[] | select(.type=="Full Time")' It produces separate JSON objects, not an array of elements. To create an array of objects, you need to wrap those two commands with square brackets: jq '[.[] | select(.type=="Full Time")]' Now it produces an array of JSON objects, and now you can pipe it with the limit instruction like this one: jq '[.[] | select(.type=="Full Time")] | [limit(3;.[])]' What you will get in result is an array of maximum 3 objects that matching the select condition.
@anuragpugalia8462
@anuragpugalia8462 4 жыл бұрын
@@szymonstepniak got it. thanks a lot for such an instant reply . thats working . Really waiting for your next set of video's.
@PaulSmith-qr1iy
@PaulSmith-qr1iy 4 жыл бұрын
Need a video explaining how to use jq with bash variables. I want to use the variable looping through the array construct. [][${i}].desired_data. Loved the intro by the way. Very pragmatic.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thanks for the kind words, Paul! I should publish another jq related video next week, I will try to do something with looping. Have a good day!
@AlbinoCordeiroJunior
@AlbinoCordeiroJunior 3 жыл бұрын
Thanks for th great video. curl is so yesterday's though :-). Give httpie a try, you won't regret
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thank you for your kind words, Albino! Yes, I love HTTPie! That's my go-to replacement for curl in 99% use cases :) Take care, and have a good day!
@yashwanthch207
@yashwanthch207 4 жыл бұрын
Hey I really like your videos and I'm happy that it's giving me some knowledge :) thanks for sharing it. I would like to check if you make videos on Yaml, Jenkins, and Kubernetes integration.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Thank you for your kind words! I made a few videos on Jenkins already, more coming soon. Have a good day!
@bendover4728
@bendover4728 3 жыл бұрын
Great!
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thanks, Ben! Take care, and have a good day!
@noxlupi1
@noxlupi1 2 жыл бұрын
Just getting "Cannot index number with string" no matter what.
@SernickTV
@SernickTV 2 жыл бұрын
"made easy" sounds funny with that syntax ;)
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Can't argue with that! 😆 Take care, and have a good day!
@cfraizer
@cfraizer 4 жыл бұрын
I love `jq`.
@szymonstepniak
@szymonstepniak 4 жыл бұрын
Same here, Colin :) Thanks for the comment! Check other two jq videos on my channel if you have time. Have a good day!
@theunderhook9913
@theunderhook9913 3 жыл бұрын
intro mega 😂😂😂😂
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Dzięki! :)
@nmcben
@nmcben Жыл бұрын
Into wasn't useful
@szymonstepniak
@szymonstepniak Жыл бұрын
Thanks for the feedback! Take care, and have a good day!
@iamfaze
@iamfaze 2 жыл бұрын
This was helpful. It would be awesome if you made a part two, some more advanced usage/tips/tricks. Like matching on a property a few scopes deep like servers.$server_names.properties.location. Thanks!
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Stay tuned, I should finally find time to work on a few more episodes explaining some useful JQ tips and tricks. Take care, and have a good day!
@kanchachina1515
@kanchachina1515 2 жыл бұрын
The image is too offensive
@szymonstepniak
@szymonstepniak 2 жыл бұрын
Thanks for your feedback, Kancha! Would you be so kind to explain what you find offensive, please? Thanks in advance! Take care, and have a good day!
@FredPhillips32169
@FredPhillips32169 3 жыл бұрын
Worst intro ever.
@szymonstepniak
@szymonstepniak 3 жыл бұрын
Thanks for your feedback, Fred! Take care, and have a good day!
@dfsgjlgsdklgjnmsidrg
@dfsgjlgsdklgjnmsidrg 4 жыл бұрын
i give you a quicktipp: less readme.md
@mietekczerniawski2439
@mietekczerniawski2439 2 жыл бұрын
「あなたのコンテンツはとても感動的です」、
EVERYONE Needs to Learn a Little Bit of AWK!
16:29
Gary Explains
Рет қаралды 400 М.
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 10 МЛН
The BEST CLI Tool
9:50
ThePrimeTime
Рет қаралды 211 М.
Merging JSON documents in the command-line - jq tutorial
9:01
Szymon Stepniak
Рет қаралды 22 М.
Using JQ to Make Magic with JSON Files
8:32
Matt Williams
Рет қаралды 3,1 М.
Is JSON Blazingly Fast or...?
9:57
ThePrimeagen
Рет қаралды 196 М.
The New Outlook is TERRIBLE
20:19
Chris Titus Tech
Рет қаралды 48 М.
This Makes Golang CLI Development So MUCH Better
7:34
Melkey
Рет қаралды 28 М.
Linux Command-Line Tips & Tricks: Over 15 Examples!
31:37
Learn Linux TV
Рет қаралды 222 М.