0

Is there a way to parse JSON without the use of additional dependencies such as jq. For example, when given:

{
  "id": 1,
  "tag_name": "v1.0.0",
  "target_commitish": "master",
  "name": "v1.0.0",
  "body": "Description of the release",
  "draft": false,
  "prerelease": false,
  "created_at": "2013-02-27T19:35:32Z",
  "published_at": "2013-02-27T19:35:32Z"
}

How can I filter out things to only get name or body in bash?

Thanks in advance

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Justin Ma
  • 11
  • 3
  • There *is* a native-shell JSON parsing library available, and there are already answers in the knowledge base linking to it. – Charles Duffy May 24 '16 at 22:57
  • ...the accepted answer on the close-as-dup requires `jsawk`, a non-default external tool, but there are other answers that meet your spec. – Charles Duffy May 24 '16 at 22:58
  • (Personally, I'm in the "install `jq`, damnit" camp, but that's neither here nor there; the specific answer covering a native-bash parser is http://stackoverflow.com/a/11524630/14122 -- and the comment suggesting https://github.com/rcrowley/json.sh is also relevant). – Charles Duffy May 24 '16 at 23:00
  • `name=$(grep '"name":' file.json | sed -e 's/"name": "\(.*\)",/\1/')`, likewise for body. – webb May 25 '16 at 04:14

0 Answers0