Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 644

Using jq to replace the value of a JSON field is not working correctly

$
0
0

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?


Viewing all articles
Browse latest Browse all 644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>