I have following the json file. I am trying to update a couple of properties in this file using jq
{
\"href\" : \"http://localhost:8080/api/v1/clu
The original question asks how to alter more than one of the "properties". The key to doing so without being repetitive is |=
. Here's an illustration:
.items[0].properties |=
( .["hfile.block.cache.size"] = "newvalue1"
| .["hbase.hregion.max.filesize"] = "newvalue2" )
The original question also mentioned updating properties within a file. One possibility that avoids having to create an explicit temporary file is to use sponge
(e.g. brew install moreutils
), along the lines of:
$ jq .... input.json | sponge input.json
Manage to do it
jq '.items[0].properties."hfile.block.cache.size"="0.2"' initial.json > 1.json