Use JQ friendly print JSON techniques under Linux to share _javascript tips

Source: Internet
Author: User

Before the command line to print JSON is all cat, and then copy the results to the editor supporting JSON resolution, very tortuous.

After a short search, an article was found on the StackOverflow. The highest support for the answer requires python2.6+ support, but the server version of 2.4, the impact of the upgrade is unpredictable, and then give up.

Continue to see the following answer, there is a small tool called JQ looks good, download the test can really meet the requirements.

#cat Food.json | JQ '. '
So you can get a well-formed result

Give us a detailed introduction to the next JQ bar

JQ Official website: http://stedolan.github.io/jq/

After downloading binary can be directly called, detailed installation see: http://stedolan.github.io/jq/download/

Simple way to use:
1,json File Friendly display

Copy Code code as follows:

Cat Jsonfile | Path_to_jq/jq.

2, get the value of a key in JSON
Copy Code code as follows:

Cat Jsonfile | PATH_TO_JQ/JQ ". Key"

More operations, see: http://stedolan.github.io/jq/manual/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.