So I have this json structure:
{
"dog": [
{
"name": "sam",
"age": "2"
},
{
"name": "billy",
"age": "5"
}
]
}
I've found that .dog[1] will return me the first object but not in the dog:[] array.
{
"name": "billy",
"age": "5"
}
and .[] |= .[$i] gives me an object:
{
"dog": {
"name": "billy",
"age": "5"
}
}
What I want is:
{
"dog": [
{
"name": "sam",
"age": "2"
}
]
}
I plan to use this in a bash script, and write out to multiple files like:
jq -r --argjson i "$i" '.[] |= .[$i]' "$1"