@@ -169,11 +169,11 @@ APIJSON是一种JSON传输结构协议。<br />
169169
170170 客户端对应不同需求的请求 | 传统方式 | APIJSON
171171-------- | ------------ | ------------
172- User | http://www.xxx.com/ get/user?id=1 | [ http://www.xxx.com /get/{"User":{"id":1}}] ( http://139.196.140.118:8080/get/{"User":{"id":38710}} )
173- Moment和对应的User | 分两次请求<br />Moment: http://www.xxx.com/ get/moment?userId=1 <br />User: http://www.xxx.com/ get/user?id=1 | [ http://www.xxx.com /get/{"Moment":{"userId":1} , "User":{"id":1}}] ( http://139.196.140.118:8080/get/{"Moment":{"userId":38710},"User":{"id":38710}} )
174- User列表 | http://www.xxx.com/ get/user/list?page=0&count=3&sex=0 | [ http://www.xxx.com /get/{"[] ":{"page":0, "count":3, "User":{"sex":0}}}] ( http://139.196.140.118:8080/get/{"[]":{"page":0,"count":3,"User":{"sex":0}}} )
175- Moment列表,每个Moment包括发布者User和前3条Comment | Moment里必须有User的Object和Comment的Array<br /> http://www.xxx.com/ get/moment/list?page=0&count=3&commentCount=3 | [ http://www.xxx.com /get/{"[] ":{"page":0, "count":3, "Moment":{}, "User":{"momentId@":"/Moment/id"}, "[ ] ":{"count":3, "Comment":{"momentId@":"[ ] /Moment/id"}}}}] ( http://139.196.140.118:8080/get/%7B%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%7D%2C%22User%22%3A%7B%22id%40%22%3A%22%252FMoment%252FuserId%22%7D%2C%22Comment%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D )
176- User发布的Moment列表,每个Moment包括发布者User和前3条Comment | http://www.xxx.com/get/moment/list?page=0&count=3&commentCount=3&userId=1 | 有以下几种方法:<br />①把以上请求里的"Moment":{}, "User":{"momentId@":"/Moment/id"}改为["Moment":{"userId":1}, "User":{"id":1}](http://139.196.140.118:8080/get/%7B%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%22userId%22%3A38710%7D%2C%22User%22%3A%7B%22id%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D) <br /><br />②或这样省去4条重复User<br />[http://www.xxx.com/get/{"User":{"id":1}, "[]":{"page":0, "count":3, "Moment":{"userId":1}, "[]":{"count":3, "Comment":{"momentId@":"[]/Moment/id"}}}}](http://139.196.140.118:8080/get/%7B%22User%22%3A%7B%22id%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%22userId%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D)<br /><br />③如果User之前已经获取到了,还可以这样省去所有重复User<br />[http://www.xxx.com/get/{"[]":{"page":0, "count":3, "Moment":{"userId":1}, "[]":{"count":3, "Comment":{"momentId@":"[]/Moment/id"}}}}](http://139.196.140.118:8080/get/%7B%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%22userId%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D)
172+ User | base_url/ get/user?id=1 | [ base_url /get/{"User":{"id":1}}] ( http://139.196.140.118:8080/get/{"User":{"id":38710}} )
173+ Moment和对应的User | 分两次请求<br />Moment: base_url/ get/moment?userId=1<br />User: base_url/ get/user?id=1 | [ base_url /get/{"Moment":{"userId":1}, "User":{"id":1}}] ( http://139.196.140.118:8080/get/{"Moment":{"userId":38710},"User":{"id":38710}} )
174+ User列表 | base_url/ get/user/list?page=0&count=3&sex=0 | [ base_url /get/{"[ ] ":{"page":0, "count":3, "User":{"sex":0}}}] ( http://139.196.140.118:8080/get/{"[]":{"page":0,"count":3,"User":{"sex":0}}} )
175+ Moment列表,每个Moment包括发布者User和前3条Comment | Moment里必须有User的Object和Comment的Array<br /> base_url/ get/moment/list?page=0&count=3&commentCount=3 | [ base_url /get/{"[ ] ":{"page":0, "count":3, "Moment":{}, "User":{"momentId@":"/Moment/id"}, "[ ] ":{"count":3, "Comment":{"momentId@":"[ ] /Moment/id"}}}}] ( http://139.196.140.118:8080/get/%7B%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%7D%2C%22User%22%3A%7B%22id%40%22%3A%22%252FMoment%252FuserId%22%7D%2C%22Comment%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D )
176+ User发布的Moment列表,每个Moment包括发布者User和前3条Comment | base_url/get/moment/list?page=0&count=3&commentCount=3&userId=1 | 有以下几种方法:<br />①把以上请求里的"Moment":{}, "User":{"momentId@":"/Moment/id"}改为["Moment":{"userId":1}, "User":{"id":1}](http://139.196.140.118:8080/get/%7B%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%22userId%22%3A38710%7D%2C%22User%22%3A%7B%22id%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D) <br /><br />②或这样省去4条重复User<br />[base_url/get/{"User":{"id":1}, "[]":{"page":0, "count":3, "Moment":{"userId":1}, "[]":{"count":3, "Comment":{"momentId@":"[]/Moment/id"}}}}](http://139.196.140.118:8080/get/%7B%22User%22%3A%7B%22id%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%22userId%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D)<br /><br />③如果User之前已经获取到了,还可以这样省去所有重复User<br />[base_url/get/{"[]":{"page":0, "count":3, "Moment":{"userId":1}, "[]":{"count":3, "Comment":{"momentId@":"[]/Moment/id"}}}}](http://139.196.140.118:8080/get/%7B%22%5B%5D%22%3A%7B%22Moment%22%3A%7B%22userId%22%3A38710%7D%2C%22%5B%5D%22%3A%7B%22Comment%22%3A%7B%22momentId%40%22%3A%22%255B%255D%252FMoment%252Fid%22%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%2C%22count%22%3A3%2C%22page%22%3A0%7D%7D)
177177
178178 服务端对应不同请求的返回结果 | 传统方式 | APIJSON
179179-------- | ------------ | ------------
@@ -185,7 +185,7 @@ APIJSON是一种JSON传输结构协议。<br />
185185
186186
1871871.APIJSON不需要接口、文档及兼容旧版客户端的特性仅针对GET和HEAD请求,好在这两个在所有请求里占大部分。<br >
188- 2.base_url指基地址,一般是顶级域名,其它分支url都是在base_url后扩展。如base_url:http://www.xxx .com/ ,对应的GET分支url:http://www.xxx .com/get/ ,下同。<br >
188+ 2.base_url指基地址,一般是顶级域名,其它分支url都是在base_url后扩展。如base_url:http://www.google .com/ ,对应的GET分支url:http://www.google .com/get/ ,下同。<br >
1891893.status,指返回结果中的状态码,200表示成功,其它都是错误码,值全部都是HTTP标准状态码。下同。<br >
1901904.message,指返回结果中的状态信息,对成功结果或错误原因的详细说明。下同。<br >
1911915.status和message总是在返回结果的同一层级成对出现。对所有请求的返回结果都会在最外层有一对总结式status和message。对非GET、HEAD请求,返回结果里面的每个JSONObject里都会有一对status和message说明这个JSONObject的状态。下同。
0 commit comments