I am trying to parse JSON data into variable format
[
{
"Name" : "a",
"Value" : "1"
},
{
"Name" : "b",
"Value" : "2"
},
{
"Name" : "c",
"Value" : "3"
}
]
output should be like
a=1
b=2
c=3
This is what I tried, but it is not giving the expected result:
jq '.[].Value' file.txt
Since you're only printing out two values, it might just be easier to print out the strings directly.
$ jq -r '.[] | "\(.Name)=\(.Value)"' file.txt
You can use the following jq command:
jq -r '.[]|[.Name,.Value]|join("=")' file.json
Output:
a=1
b=2
c=3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With