I have the following json
[ { "name":"bucket1" }, { "name":"bucket1" } ]
I want to convert it to
{ "buckets":[ { "name":"bucket1" }, { "name":"bucket1" } ] }
How do I do this with jq?
Advertisement
Answer
The solution is the following:
{"buckets":.}
In the Command line:
jq '{"buckets":.}'
See:https://jqplay.org/s/MJ-GoLOBX2
There is more documentation available at:
https://programminghistorian.org/en/lessons/json-and-jq#the-dot-
Also see the hints below jqplay at the bottom.