From zero-learning JSON JSON data structure _ basics

Source: Internet
Author: User
Tags in python

Recently in the development of micro-trust platform, to use JSON for data exchange, before using JSON, but limited to ...

In developing a micro-trust platform, use the JSON form as follows:
Code Snippet 1:

Copy Code code as follows:

{
"Button": [
{
' Type ': ' Click ',
"Name": "Today's Song",
"Key": "V1001_today_music"
},
{
' Type ': ' Click ',
"Name": "Singer Profile",
"Key": "V1001_today_singer"
},
{
' Name ': ' Menu ',
"Sub_button": [
{
"Type": "View",
' Name ': ' Search ',
"url": "http://www.soso.com/"
},
{
"Type": "View",
' Name ': ' Video ',
"url": "http://v.qq.com/"
},
{
' Type ': ' Click ',
"Name": "Praise Us",
"Key": "V1001_good"
}]
}]
}

Then use PHP's Json_encode () function to convert the one or two-D array to JSON form

But the converted JSON form:
Code Snippet 2:

Copy Code code as follows:

{
"button": {
"1": {
' Type ': ' Click ',
"Name": "Today's Song",
"Key": "V1001_today_music"
},
"2": {
' Type ': ' Click ',
"Name": "Singer Profile",
"Key": "V1001_today_singer"
},
"3": {
' Name ': ' Menu ',
"Sub_button": [
{
"Type": "View",
' Name ': ' Search ',
"url": "http://www.soso.com/"
},
{
"Type": "View",
' Name ': ' Video ',
"url": "http://v.qq.com/"
},
{
' Type ': ' Click ',
"Name": "Praise Us",
"Key": "V1001_good"
}
]
}
}
}

See the form is inconsistent.

The

can only take a look at the structural form of JSON.
JSON has two kinds of data: 1. Unordered object structure; 2. Ordered array structure
1. Unordered object structure
The disordered object structure is called different in different languages, such as in Python, called a dictionary, called a JSON object in JS ... The
is a combination of key/value pairs in summary.
The JSON structure I converted just now is an unordered combination of key/value pairs
2. Ordered array structure
ordered array structure, which is the structure shown by code fragment 2. The
converts the array to JSON as an ordered array, and you get an ordered JOSN array structure.

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.