I'm parsing below JSON
using jq
in my shell script, but I'm getting null
while parsing this field config.subtype
. And I want to check if config.subtype
value is mobile
, I want to update the value as 1000
for this field config.price
and print the complete JSON. What I'm doing wrong here and how to update the existing JSON field value.
Appreciated your help in advance! Thanks!
Please find my code below:
test.json
{
"name": "myapp",
"product": {
"config.type": "electronics",
"config.count": "5",
"config.subtype": "mobile",
"config.price": ""
}
}
test.sh
#!/bin/bash
#
result=$(cat test.json| jq '.product.config.type')
echo $result