JSON数据格式(键值对)(一)

简介

是一种数据格式,结构为键值对的方式存储和传输,例如

第一个JSON格式

JSON 对象在大括号({})中书写:

对象可以包含多个名称/值对:

{

 "name":"这是一个名字" ,

"url":"www.runoob.com"

}

JSON 数组

{

    "sites": [

    { "name":"第一个名字" , "url":"www.diyigemignzi.com" },

    { "name":"google" , "url":"www.google.com" },

    { "name":"微博" , "url":"www.weibo.com" }

    ]

}

 

JSON 布尔值

JSON 布尔值可以是 true 或者 false:

{ "flag":true }

嵌套的JSON对象

{

    "name":"runoob",

    "alexa":10000,

    "sites": {

        "site1":"www.runoob.com",

        "site2":"m.runoob.com",

        "site3":"c.runoob.com"

    }

}

JSON 对象中的数组

{

"name":"网站",

"num":3,

"sites":[ "Google", "Runoob", "Taobao" ]

}

 

JSON嵌套数组

{

    "name":"网站",

    "num":3,

    "sites": [

        { "name":"Google", "info":[ "Android", "Google 搜索", "Google 翻译" ] },

        { "name":"名字", "info":[ "第一个名字", "第二个名字", "第三个名字" ] },

        { "name":"网购", "info":[ "淘宝", "京东" ] }

    ]

}

猜你喜欢

转载自blog.csdn.net/yuupengsun/article/details/114240496
今日推荐