JSON data Format understanding

Source: Internet
Author: User

JSON data Format Description:

Https://en.wikipedia.org/wiki/JSON

JSON (JavaScript Object Notation) is a lightweight data interchange format

JSON syntax is a subset of JavaScript Object notation syntax:

    • Key-value pairs
    • Comma delimited
    • Curly braces Save Object
    • Square brackets Data

The key (field name) of the JSON is a string (double quotation marks)

The JSON value can be a number, a string, a logical value (True, false), an array (square brackets), an object (nested in curly braces), null

JSON file type: ". JSON"

Chestnuts:

{"Employees": [{true},{false},],"department": [{" Name ":" Tieba "," Emp_num ":" Location ": 2} {" name ":" Baike "," Emp_num ": $," location ": 3}]}

Parsing of JSON files:

shell:http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=4131068

      • JQ
        • Read a row of fields
          • Local address= ' JQ. Employee[0].name tt.json ' (address variable is quoted "Peter")

Local address= ' JQ. Employee[0].name Tt.json | Sed ' s/\ '//g ' (replace double quotes with SED)

        • View JSON file contents
          • JQ. Tt.json
        • Find Values by key
          • JQ. Employee Tt.json
        • Select query
          • JQ '. employee[] | Select (. name== ' Jone ') ' Tt.json
      • Json.sh (a pipeable JSON parser written in Bash)
        https://github.com/dominictarr/JSON.sh

Python:

JSON module: Used to convert between string and Python data types, and data serialization module Pickle uses the same

The JSON module provides four functions: dumps, dump, loads, load

ImportJsondata= {"name":"Police","Phone": [110, 911]}#JSON data equivalent to Python dictionary#write JSON format to fileWith Open ('Test.json','W') as Of:json.dump (data, of)#reading JSON filesWith Open ('Test.json','R') as Of:data= Json.load (OF)

Java

Reference: http://json.cn/json/code.html, also includes PHP and JavaScript construction parsing method

Two methods: Json_lib http://www.cnblogs.com/lanxuezaipiao/archive/2013/05/23/3096001.html

Json_lib need to rely on Ezmorph and Commons's lang, logging, Beanutils, collections and other components

Org.json http://www.cnblogs.com/lanxuezaipiao/archive/2013/05/24/3096437.html

Org.json package has no other dependencies, complete beans, collections, maps, arrays and XML and JSON conversions

The above link article provides a URL http://www.json.org/, a variety of language parsing JSON data tools are basically listed

     

JSON data Format understanding

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.