JSON格式

案例一:

{key:value,key:value}

var person={"firstname":"张","lastname":"三","age":"16"};

alert(person.lastname);------>三

案例二:

[{key:value,key:value},{key:value,key:value}]

var persons=[{"firstname":"张","lastname":"三","age":"16"},{"firstname":"李","lastname":"四","age":"20"}];

alert(persons[1].firstname);------>李

案例三:

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

var json={

        "baobei":[

                {"name":"小爽","age":"16","addr":"扬州"},

                {"name":"阿珂","age":"40","addr":"陕西"},

                {"name":"建宁","age":"20","addr":"南京"},

        ]

};

alert(json.baobei[1].name);------>阿珂

案例四:

{

"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={

        "baobei":[

                {"name":"小爽","age":"16","addr":"扬州"},

                {"name":"阿珂","age":"40","addr":"陕西"},

                {"name":"建宁","age":"20","addr":"南京"},

        ],

   "bao":[

                {"name":"张爽","age":"66","addr":"山西"},

                {"name":"阿宝","age":"42","addr":"陕西"}

        ]

};

alert(json.bao[1].name);------>阿宝

案例五:

{

"param1":"value1",

"param2":{},

"param3":[{key:value,key:value},{key:value,key:value}]

}

var json={

        "key1":"value1",

        "key2":{"firstname":"张","lastname":"三","age":"16"},

        "key3":[

                {"name":"小爽","age":"16","addr":"扬州"},

                {"name":"阿珂","age":"40","addr":"陕西"},

                {"name":"建宁","age":"20","addr":"南京"},

        ]

};

alert(json.key3[1].name);------>阿珂

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值