I'm adding a property to a JSON string with
result=$(jq -c ".docs[$docIndex] + { \"value\": \"value\" }"<<<"$fileContent")
Where the JSON inside $fileContent
is
{
"docs": [
{
"id": 123
},
{
"id": 456
},
{
"id": 678
},
...
]
}
But what is inside $result
after my operation is {"id:123", "value":"value"}
. How do I return the full output? What I would like is that result becomes
{
"docs": [
{
"id": 123,
"value": "value"
},
{
"id": 456
},
{
"id": 678
},
...
]
}
+=
instead of+
? – Romeo Ninov Jun 19 '17 at 08:36