The difference between PHP to the mobile interface [] and {}

Source: Internet
Author: User

Write to the mobile interface, the JSON data, sometimes {} sometimes is [] , I always silly, and then check the JSON data structure;

We need to understand what JSON is;

    • JSON refers to the JavaScript object notation (JAvaScript Object Notation)
    • JSON is a lightweight text data interchange Format
    • JSON independent of Language *
    • JSON is self-descriptive and easier to understand

The format of JSON is

If it is a {} object, then it is the format of the Key:value one is connected with a comma of "," in English;

If it is an [] array, then only the value, the format of value, is concatenated with a comma of "," in English;

{} and [] can be nested with each other, but there must be an end at the beginning;

Object:{}The data structure is a key-value pair structure of {key1:value1, key2:value2, ...}, array: [] data structure for ["Java", "JavaScript", "VB", ...] index structure,
For a chestnut: PHP data structure
EchoJson_encode ([[' A '],[[' B '],[[1,2,  ' 3 '=4] ]],  json_unescaped_unicode);

The Json_encode output of the page is as follows;

For data that goes to JSON, there are []There are some of the essential differences of {} , that is, the problem of data structure, there is a key value to that is {} is treated as object; as array processing,
This is a fuzzy idea of the JSON data structure,

The difference between PHP to the mobile interface [] and {}

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.