I have the following json
JavaScript
x
[
{
"name":"bucket1"
},
{
"name":"bucket1"
}
]
I want to convert it to
JavaScript
{
"buckets":[
{
"name":"bucket1"
},
{
"name":"bucket1"
}
]
}
How do I do this with jq?
Advertisement
Answer
The solution is the following:
JavaScript
{"buckets":.}
In the Command line:
JavaScript
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.