json格式例子

分类: 随笔 发布时间: 2017-08-26 19:56

json数据格式可以表示名称/值对,也可以表示数组,是现在流行的数据通讯格式。为了防止自己忘记json的格式,先记录下来三个简单的例子。后续添加C++对该格式的解析。

简单的名称/值 对格式:

{ “firstName”:”Brett”, “lastName”:”McLaughlin”, “email”:”aaaa” }

表示数组

{ “people”: [ {“firstName”:”Brett”, “lastName”:McLaughlin, “email”:”aaaa”},

{“firstName”:”jason”, “lastName”:”Hunter”,”email”:”bbbb”},

{“firstName”:”Elliotte”, “lastName”:”Harold”, “email”:”cccc”}

]}

 

{ “programmers”:[

{“firstName”:”Brett”, “lastName”:McLaughlin, “email”:”aaaa”},

{“firstName”:”jason”, “lastName”:”Hunter”,”email”:”bbbb”},

{“firstName”:”Elliotte”, “lastName”:”Harold”, “email”:”cccc”}

],

“authors”:[

{ “firstName”: “Isaac”, “lastName”:”Asimov”, “genre”:”science fiction” },

{“firstName”:”Tad”, “lastName”:”Williams”,”genre”:”fantasy”},

{“firstName:”Frank”,”lastName”:”Peretti”,”genre”:”christian fiction” }

],

“musicians”:[

{ “firstName”:”Eric”, “lastName”:”Clapton”,”instrument”:”guitar” },

{“firstName”:”Sergei”,”lastName”:”Rachmaninoff”,”instrument”:”piano”}

]

}

 

 

 

 


如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!