Command line JSON tool under Linux: JQ

Source: Internet
Author: User
Yum Install Jq-y

Prerequisites JSON:
{"PHP": [{"Name": "A1", "Age": 15},{"Name": "A2", "Age": +}], "Python": [{"Name": "B1", "Age": 15},{"name": "B2", "Age": 18} ]}

Case 1: Formatting the JSON
PHP test.php |JQ.

Case 2: Take out a key all
PHP test.php |jq. php

Case 3: Remove all keys from a key
PHP test.php |jq. PHP|JQ keys
Or
PHP test.php |jq. PHP[1]|JQ keys

Case 5: Determine if a key exists:
PHP test.php |jq. Php[1]|jq ' Have ("age") '

Case 6: Remove a key from a field all
PHP test.php |jq. python[].age
Or
PHP test.php |jq '. php[]| {Age,name} '

Case 7: Customizing out certain fields
PHP test.php |jq '. python[1]| {Age,name} '

Case 8: Remove a key from a field
PHP test.php |jq '. Python[].age '

Official manual: https://stedolan.github.io/jq/manual/

Command line JSON tool under Linux: JQ

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.