I have a template JSON file like this:
[
{
"fields": [
{
"name": "body_t",
"value": "TEST"
}
],
"id": "abc123"
}
]
I need to replace the "value" of the "body_t" (which is set to TEST in the template).
jq '.[].fields[] | select(.name == "body_t") | .value = "'"TEST"'"' template.json
I receive back the following error:
Cannot index string with string "fields"
What am I doing wrong here?
2
Answers
What I would do:
If you want to keep the original structure, I’d use:
JqPlay Demo