码迷,mamicode.com
首页 > Web开发 > 详细

Json总结

时间:2014-12-01 15:46:16      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   os   sp   strong   on   div   

Json格式

基本格式

变量名:值

"title":"肖申克的救赎"

 

值可以是结构体(类),如下,用大括号括起来:

"images":
{"small":"http:\/\/img3.douban.com\/view\/movie_poster_cover\/ipst\/public\/p480747492.jpg",
"large":"http:\/\/img3.douban.com\/view\/movie_poster_cover\/lpst\/public\/p480747492.jpg",
"medium":"http:\/\/img3.douban.com\/view\/movie_poster_cover\/spst\/public\/p480747492.jpg"},

 

值可以是数组,如下,用中括号括起来:

"genres":["犯罪","剧情"],

 

数组可以由结构体(类)构成:

"casts":[
{"avatars":{"small":"http:\/\/img3.douban.com\/img\/celebrity\/small\/17525.jpg","large":"http:\/\/img3.douban.com\/img\/celebrity\/large\/17525.jpg","medium":"http:\/\/img3.douban.com\/img\/celebrity\/medium\/17525.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1054521\/“,”id":"1054521",
"name":"蒂姆·罗宾斯"},

{"avatars":{"small":"http:\/\/img3.douban.com\/img\/celebrity\/small\/34642.jpg","large":"http:\/\/img3.douban.com\/img\/celebrity\/large\/34642.jpg","medium":"http:\/\/img3.douban.com\/img\/celebrity\/medium\/34642.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1054534\/",
"id":"1054534",
"name":"摩根·弗里曼”},

{“avatars":{"small":"http:\/\/img5.douban.com\/img\/celebrity\/sL;POL,mall\/5837.jpg","large":"http:\/\/img5.douban.com\/img\/celebrity\/large\/5837.jpg","medium":"http:\/\/img5.douban.com\/img\/celebrity\/medium\/5837.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1041179\/",
"id":"1041179",
"name":"鲍勃·冈顿"}],

 

举例

http://api.douban.com/v2/movie/top250

{"rating":{"max":10,"average":9.6,"stars":"50","min":0},
"genres":["犯罪","剧情"],
"collect_count":783892,

"casts":[
{"avatars":{"small":"http:\/\/img3.douban.com\/img\/celebrity\/small\/17525.jpg","large":"http:\/\/img3.douban.com\/img\/celebrity\/large\/17525.jpg","medium":"http:\/\/img3.douban.com\/img\/celebrity\/medium\/17525.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1054521\/“,”id":"1054521",
"name":"蒂姆·罗宾斯"},

{"avatars":{"small":"http:\/\/img3.douban.com\/img\/celebrity\/small\/34642.jpg","large":"http:\/\/img3.douban.com\/img\/celebrity\/large\/34642.jpg","medium":"http:\/\/img3.douban.com\/img\/celebrity\/medium\/34642.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1054534\/",
"id":"1054534",
"name":"摩根·弗里曼”},

{“avatars":{"small":"http:\/\/img5.douban.com\/img\/celebrity\/sL;POL,mall\/5837.jpg","large":"http:\/\/img5.douban.com\/img\/celebrity\/large\/5837.jpg","medium":"http:\/\/img5.douban.com\/img\/celebrity\/medium\/5837.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1041179\/",
"id":"1041179",
"name":"鲍勃·冈顿"}],


"title":"肖申克的救赎",
"original_title":"The Shawshank Redemption",
"subtype":"movie",
"directors":

[{"avatars":
{"small":"http:\/\/img3.douban.com\/img\/celebrity\/small\/230.jpg","large":"http:\/\/img3.douban.com\/img\/celebrity\/large\/230.jpg","medium":"http:\/\/img3.douban.com\/img\/celebrity\/medium\/230.jpg"},
"alt":"http:\/\/movie.douban.com\/celebrity\/1047973\/",
"id":"1047973",
"name":"弗兰克·德拉邦特"}],

"year":"1994",
"images":
{"small":"http:\/\/img3.douban.com\/view\/movie_poster_cover\/ipst\/public\/p480747492.jpg",
"large":"http:\/\/img3.douban.com\/view\/movie_poster_cover\/lpst\/public\/p480747492.jpg",
"medium":"http:\/\/img3.douban.com\/view\/movie_poster_cover\/spst\/public\/p480747492.jpg"},

"alt":"http:\/\/movie.douban.com\/subject\/1292052\/",
"id":"1292052"},

 

Json总结

标签:blog   http   io   ar   os   sp   strong   on   div   

原文地址:http://www.cnblogs.com/zhongriqianqian/p/4135119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!