I recently used JSON for data exchange on the development platform. I used JSON before, but it is limited ......
In the development platform, the JSON format should be used as follows:
Code snippet 1:
{"Button": [{"type": "click", "name": "Today's songs", "key": "V1001_TODAY_MUSIC" },{ "type ": "click", "name": "", "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": "like us ", "key": "V1001_GOOD"}]}
Then use the json_encode () function of PHP to convert a two-dimensional array into a JSON format.
However, the converted JSON format is as follows:
Code snippet 2:
{"Button": {"1": {"type": "click", "name": "Today's songs", "key": "V1001_TODAY_MUSIC "}, "2": {"type": "click", "name": "", "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 ": "like us", "key": "V1001_GOOD"}] }}
The format is inconsistent.
You can only understand the JSON structure.
JSON has two types of data: 1. unordered object structure; 2. ordered array structure.
1. unordered object structure
Unordered object structures have different naming rules in different languages. For example, they are called dictionaries in Python and JSON objects in JS ......
In short, it is a combination of key/value pairs.
The JSON structure I just converted is a combination of unordered key/value pairs.
2. ordered array structure
An ordered array structure, that is, the structure displayed by code snippet 2.
Convert an array into JSON as an ordered array to obtain an ordered JOSN array structure.