JSON format Example

Source: Internet
Author: User

Case one:

{Key:value,key:value}

class person{         = "Zhang";          = "San Fung";          = +;      }             New Person ();      System.out.println (p.firstname);

Turn JS:

var person = {"FirstName": "Zhang", "LastName": "Three Abundant", "age":           // Remove LastName      alert (person.lastname);      // Remove Age     alert (person.age);

Case TWO:
[{Key:value,key:value},{key:value,key:value}]

    New Person[1];     New Person ("Zhang", "San Feng", "three"    );new person ("Li", "Four", "    persons[");0] = p0;    persons[1] = P1;    System.out.println (persons[0].age);    System.out.println (persons[1].firstname);

Turn JS:

var persons = [              {"FirstName": "Zhang", "LastName": "Sanfeng", "age": +},                 {"FirstName": "Li", "LastName": "Four", "Age": [+               ]]     ; // Take out Fistname= Lee     Alert (persons[1].firstname);      // Remove age=100     alert (persons[0].age);

Case THREE:

"param": [{Key:value,key:value},{key:value,key:value}]

 var  json = { "Baobao" :[{ "name": "YG", age:22, "addr": "Nantong" },             { "name": "Gy", age:22, "addr": "Xuzhou" }]     };  //  take name = Gy  alert (json.baobao[1<     Span style= "COLOR: #000000" >].name);  //  take addr = Nantong  alert (json.baobao[0<    Span style= "COLOR: #000000" >].addr); 

Case FOUR:
      {
        ' param1 ': [{key:value,key:value},{ Key:value,key:value}],
        "param2": [{key:value,key:value},{key:value,key: Value}],
        "param3": [{key:value,key:value},{key:value,key:value}]
     }

 var  json = { "Baobao" :[{ "name": "YG", age:22, "addr": "Nantong" },                 { "name": "Gy", age:22, "addr": "Xuzhou" }],                            "Haohao": [{"Name": "XH", age:23, "addr": "Nanjing" }, { "name": "AJ", Age:22, "addr": "Huaiyin" }]};  //  take name = Gy  alert (json.baobao[1].name);  //  take addr = Huaiyin  alert (json.haohao[1].addr); 

Case FIVE:
{
"param1": "Value1",
"Param2": {},
"Param3": [{Key:value,key:value},{key:value,key:value}]
}

var json = {                 "Key1": "Value1",                 "Key2": {"FirstName": "Zhang", "LastName": "Sanfeng", "Age" : "Key3": [                       {"name": "YG", age:22, "addr": "Nantong"},                        {"name": "Gy", age:22,                 "Addr": "Xuzhou"}                                         ]              ;     alert (json.key2.firstname);     Alert (json.key3[1].age);

JSON format Example

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.