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

แชร์
ฝัง

ความคิดเห็น • 114

  • @szymonstepniak
    @szymonstepniak  4 ปีที่แล้ว +37

    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 ปีที่แล้ว +1

      Liked it

    • @viswagb
      @viswagb 3 ปีที่แล้ว

      very cool

    • @fleurdevries3121
      @fleurdevries3121 ปีที่แล้ว +1

      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. 😅

  • @TomS-g2p
    @TomS-g2p ปีที่แล้ว +1

    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 :)

  • @jsaenzMusic
    @jsaenzMusic ปีที่แล้ว +1

    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!

  • @MrSuriyam
    @MrSuriyam 5 หลายเดือนก่อน

    Thank you 🙏 for putting together a wonderful training and easy to understand. Appreciate your time sir.

  • @HarshDeep61034
    @HarshDeep61034 ปีที่แล้ว +2

    Love the intro and story telling ❤
    And off course the video is on point

    • @szymonstepniak
      @szymonstepniak  ปีที่แล้ว +1

      Thank you so much!! Take care, and hava a good day!

    • @HarshDeep61034
      @HarshDeep61034 ปีที่แล้ว

      @@szymonstepniak you too ❤️

  • @nuriaarlandishernandez5168
    @nuriaarlandishernandez5168 3 ปีที่แล้ว +1

    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!

  • @mmu99
    @mmu99 2 ปีที่แล้ว +1

    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!

  • @rafaotetra
    @rafaotetra 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      Thank you for your kind words, Rafael! Take care, and have a good day!

  • @manuelajannusch8208
    @manuelajannusch8208 2 ปีที่แล้ว +1

    Mesej yang jelas, struktur yang jelas, mudah difahami, terima kasih

  • @michaelbanzato6246
    @michaelbanzato6246 2 ปีที่แล้ว +1

    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!

  • @buf0rd
    @buf0rd 2 ปีที่แล้ว +1

    Great video. Straight to the point!

    • @szymonstepniak
      @szymonstepniak  2 ปีที่แล้ว

      Glad to hear that! Take care, and have a good day!

  • @Megalcristo2
    @Megalcristo2 2 ปีที่แล้ว +1

    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!

  • @michaeldsouza7591
    @michaeldsouza7591 2 ปีที่แล้ว +1

    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.

  • @СержХолодилов-ж7ь
    @СержХолодилов-ж7ь 2 ปีที่แล้ว +1

    「あなたのコンテンツはとても感動的です」、

  • @giaotran2018
    @giaotran2018 2 ปีที่แล้ว +1

    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!

  • @mlnw193
    @mlnw193 3 ปีที่แล้ว +1

    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

  • @CaimAstraea
    @CaimAstraea 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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!

  • @j_holtslander
    @j_holtslander 4 ปีที่แล้ว +2

    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 ปีที่แล้ว +2

      Solved. I needed .[] to be .data[]

    • @szymonstepniak
      @szymonstepniak  4 ปีที่แล้ว +1

      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!

  • @teengohan.ssj223
    @teengohan.ssj223 2 ปีที่แล้ว +1

    God bless u sir. Thank you very much

  • @1bigslug
    @1bigslug 3 ปีที่แล้ว +1

    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!

  • @davidkuda7074
    @davidkuda7074 3 ปีที่แล้ว +1

    That's an excellent video, thanks.

    • @szymonstepniak
      @szymonstepniak  3 ปีที่แล้ว

      Thank you so much for your kind words! Take care, and have a good day!

  • @dm.vortex4171
    @dm.vortex4171 4 ปีที่แล้ว +1

    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

  • @matthiasdebernardini3388
    @matthiasdebernardini3388 3 ปีที่แล้ว +1

    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.

  • @testexample2729
    @testexample2729 4 ปีที่แล้ว

    Very informative your videos. Thanks a lot. Keep it up.

  • @tldc
    @tldc 2 ปีที่แล้ว +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!

  • @RamkrishanYT
    @RamkrishanYT 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      I'm glad to hear that the video was helpful, Ram! Take care, and have a good day!

  • @PaulSmith-qr1iy
    @PaulSmith-qr1iy 4 ปีที่แล้ว +1

    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!

  • @hoannguyen2219
    @hoannguyen2219 2 ปีที่แล้ว +1

    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!

  • @georgechacko4276
    @georgechacko4276 3 ปีที่แล้ว +1

    Very helpful thanks.

    • @szymonstepniak
      @szymonstepniak  3 ปีที่แล้ว

      You're welcome! Take care and have a good day!

  • @horizonlimit89
    @horizonlimit89 4 ปีที่แล้ว +2

    yes more of jq content would be nice.

    • @szymonstepniak
      @szymonstepniak  4 ปีที่แล้ว +1

      Thanks Shitiz, more jq videos soon :)

  • @ravikumarhr4524
    @ravikumarhr4524 4 ปีที่แล้ว +1

    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 - th-cam.com/video/FSn_38gDvzM/w-d-xo.html Have a good day!

  • @niteshsinghal88
    @niteshsinghal88 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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 :)

  • @Bodybuilder900ml
    @Bodybuilder900ml ปีที่แล้ว +1

    Thank you sir!

  • @mohammadrezabooshehri6621
    @mohammadrezabooshehri6621 3 ปีที่แล้ว +1

    Thanks, it was very useful. please share the reference which you've learned jq with us.

    • @szymonstepniak
      @szymonstepniak  3 ปีที่แล้ว +1

      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!

  • @tommynotts1400
    @tommynotts1400 4 ปีที่แล้ว +1

    Very useful. Thank you.

    • @szymonstepniak
      @szymonstepniak  4 ปีที่แล้ว

      Thank you, Thomas, for the comment! I'm glad to hear this video was useful.

  • @alexandrutudosan3319
    @alexandrutudosan3319 3 ปีที่แล้ว +1

    great tutorial

    • @szymonstepniak
      @szymonstepniak  3 ปีที่แล้ว

      Thank you so much for your kind words, Alexandru! Take care, and have a good day!

  • @toanvo618
    @toanvo618 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

    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 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +1

      @@szymonstepniak got it. thanks a lot for such an instant reply . thats working . Really waiting for your next set of video's.

  • @noxlupi1
    @noxlupi1 2 ปีที่แล้ว

    Just getting "Cannot index number with string" no matter what.

  • @AlbinoCordeiroJunior
    @AlbinoCordeiroJunior 3 ปีที่แล้ว +1

    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!

  • @SernickTV
    @SernickTV 2 ปีที่แล้ว +1

    "made easy" sounds funny with that syntax ;)

    • @szymonstepniak
      @szymonstepniak  2 ปีที่แล้ว +1

      Can't argue with that! 😆 Take care, and have a good day!

  • @bendover4728
    @bendover4728 3 ปีที่แล้ว +1

    Great!

    • @szymonstepniak
      @szymonstepniak  3 ปีที่แล้ว +1

      Thanks, Ben! Take care, and have a good day!

  • @cfraizer
    @cfraizer 4 ปีที่แล้ว +1

    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!

  • @yashwanthch207
    @yashwanthch207 4 ปีที่แล้ว +1

    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!

  • @iamfaze
    @iamfaze 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      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!

  • @theunderhook9913
    @theunderhook9913 3 ปีที่แล้ว +1

    intro mega 😂😂😂😂

  • @nmcben
    @nmcben ปีที่แล้ว +3

    Into wasn't useful

    • @szymonstepniak
      @szymonstepniak  ปีที่แล้ว

      Thanks for the feedback! Take care, and have a good day!

  • @kanchachina1515
    @kanchachina1515 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +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 ปีที่แล้ว +1

    「あなたのコンテンツはとても感動的です」、