I _love_ jq. It's been an incredibly useful tool for me since I discovered it ~6 months ago. However, article mentions "jq -n"; I personally find jq syntax less appealing when it comes to generating JSON instead of parsing it. For that particular task, I prefer using "jo":
https://github.com/jpmens/jo
jq & jo are the Calvin & Hobbes of the shell: lots of fun together!
A few examples:
- Generate a simple JSON object:
- Want a nested object? - What about arrays? - Now let's add some jq magic to sum all the values in the array together: Great stuff :)