Command to keep only a portion of JSON data from each line?
With a proper jq tool:
jq -c '{"b": .b}' test.json
The output:
{"b":"sd"}
{"b":"bfgg"}
With Miller
$ mlr --json cut -f b test.json
{ "b": "sd" }
{ "b": "bfgg" }
Using the json json parser:
json -f test.json -gac 'return console.log("{ \"b\": \"" + this.b + "\" }")'
In this case jq
seems like a better tool for this but I still think json
is a really great tool for parsing json data.