Posts

Showing posts with the label json

jq: Quick Start and Command Example

This post shows examples of jq usage. what is jq? jq is a command-line JSON parser. It can pretty print JSON, access specified keys & values, etc. install % brew install jq % jq --version jq-1.6 sample.json Assume that you have un-formatted json as a API-call result. [{"name":"n1","created":"2021-02-15","settings":[{"name":"setting1","value":"value1"},{"name":"setting2","value":"value2"}]},{"name":"n2","created":"2021-02-16","settings":[{"name":"setting1","value":"value1"}]}] examples pretty format % cat sample.json | jq . [   {     "name" : "n1" ,     "created" : "2021-02-15" ,     "settings" : [       {         "name" : "setting1" ,         "value" : "value1"       },       {...