Answers for "read json format in terminal"

10

json formatter terminal

# How to encode JSON as a string
import json
print(json.dumps({'a': 1, 'b': 2}) # '{ "a": 1, "b": 2 }'
print(json.dumps({'b': 1, 'a': 2}, sort_keys=True, indent=4))
# {
#    "a": 2,
#    "b": 1
# }
Posted by: Guest on May-31-2021
0

terminal read json file

#install jq to read/process json file, and run the following
jq . filename.json

#filter complex json file with jq and grep
jq . filename.json | grep "text_string"
Posted by: Guest on August-31-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language