Home >Web Front-end >JS Tutorial >Sharing of JSON-friendly printing techniques using jq under Linux_javascript techniques
When I printed JSON on the command line before, it was always Cat, and then I copied the result to an editor that supports JSON parsing, which was very tortuous.
After a simple search, I found an article on StackOverflow. The answer with the highest support rate requires the support of Python2.6, but the version on the server is 2.4. The impact of the upgrade is unpredictable, so I gave up.
Continue to read the answers below. There is a small tool called jq that seems to be pretty good. Download it and test it and it can indeed meet the requirements.
#cat food.json | jq '.'
You can get the formatted results
Let me introduce jq to you in detail
jq official website: http://stedolan.github.io/jq/
After downloading the binary, you can call it directly. For detailed installation, please see: http://stedolan.github.io/jq/download/
Easy to use:
1. Friendly display of json files
For more operations, see: http://stedolan.github.io/jq/manual/