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.