How to get the keys / values ​​of the json file using grep / awk / sed?

advertisements

This question already has an answer here:

  • Parsing JSON with Unix tools 40 answers

Whats the best way to extract key/values from a json file using grep/sed/awk.Or should I just use jq?


Grep exclusively uses regular expressions, which cannot parse recursive grammars such as JSON. You can probably write a JSON parser using sed or awk, but the sed/awk program will likely be comparatively large and unwieldy.

Use jq or some other tool/library specifically designed for parsing JSON.