1
{
  "test1": {
    "type": "string",
    "value": "foo"
  },
  "test2": {
    "type": "string",
    "value": "bar"
  }
}

In a json like above I need to get extract the following details. Assuming that I have to extract the key and the value both.

test1=foo

test2=bar

Is there anyway this is possible through bash?

ctienshi
  • 123
  • 1
  • 6
  • Check this question: https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools – JayJay Jan 21 '21 at 19:03

1 Answers1

1

Found the answer. You can do it by the following code.

jq -r 'keys[] as $k | "\($k) \(.[$k].value)"' tmp.json
ctienshi
  • 123
  • 1
  • 6