@@ -18,17 +18,17 @@ APIJSON是一种JSON传输结构协议。<br />
1818
1919<p >{<br />
2020  ;   ; " ; [ ] " ; : {   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ; //请求一个array<br />
21-   ;   ;   ;   ; " ; @ page " ; : 1,   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ; //array条件<br />
22-   ;   ;   ;   ; " ; @ count " ; : 2,   ;   ;   ;   ; <br />
21+   ;   ;   ;   ; " ; page" ; : 1,   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ; //array条件<br />
22+   ;   ;   ;   ; " ; count" ; : 2,   ;   ;   ;   ; <br />
2323  ;   ;   ;   ; " ; User" ; : {   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ; //请求查询名为User的table,返回名为User的JSONObject<br />
2424  ;   ;   ;   ;   ;   ; " ; sex" ; : 0   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ; //object条件<br />
2525  ;   ;   ;   ; },<br />
2626  ;   ;   ;   ; " ; Work" ; : {<br />
2727  ;   ;   ;   ;   ;   ; " ; userId@" ; : &ldquo ; /User/id&rdquo ;   ;   ;   ;   ;   ;   ; //缺省依赖路径,从同级object的路径开始<br />
2828  ;   ;   ;   ; },<br />
2929  ;   ;   ;   ; " ; Comment[ ] " ; : {   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ;   ; //请求一个名为Comment的array  ; <br />
30-   ;   ;   ;   ;   ;   ; " ; @ page " ; : 0,<br />
31-   ;   ;   ;   ;   ;   ; " ; @ count " ; : 3,<br />
30+   ;   ;   ;   ;   ;   ; " ; page" ; : 0,<br />
31+   ;   ;   ;   ;   ;   ; " ; count" ; : 3,<br />
3232  ;   ;   ;   ;   ;   ; " ; Comment" ; : {<br />
3333  ;   ;   ;   ;   ;   ;   ;   ;   ;" ; workId@" ; : &ldquo ; [ ] /Work/id&rdquo ;   ; //完整依赖路径<br />
3434  ;   ;   ;   ;   ;   ;   ; }<br />
@@ -171,7 +171,7 @@ APIJSON是一种JSON传输结构协议。<br />
171171 "key()":"函数表达式", 函数表达式为 function(Type0: value0 ,Type1: value1 ...) | 表示查询后远程调用函数 | "isPraised()":"contains(Collection: praiseUserIdList ,userId)",请求完成后会调用 boolean contains(Collection collection, Object object) 函数,然后变为 "isPraised": true 这种(假设点赞用户id列表包含了userId,即这个User点了赞)。函数参数类型为Object时可用 value 替代 Object: value 。
172172 "key@":"依赖路径",依赖路径为用/分隔的字符串 | 表示依赖引用 | "userId@":"/User/id",userId依赖引用同级User内的id值,假设id=1,则请求完成后会变成 "userId":1
173173 "key$":"SQL搜索表达式",任意标准SQL搜索表达式字符串,如 %key%, %k%e%y% 等 | 表示查询时模糊搜索 | "name$":"%Tommy%",搜索包含Tommy的名字。一般用于查询一个数组。请求 {"[ ] ":{"User":{"name$":"%Tommy%"}}} 会返回name包含"Tommy"的User数组。
174- "@key ":任意Object | @key 为关键字 ,作用各不相同,但都不作为查询匹配条件 | ① "@page ":1,页码为1;< br /> ② " @ count ":10,数组长度最大为10;< br /> ③ " @ columns ":"id,sex,name",只查询id,sex,name这几个字段;<br />④ 从pictureList获取第0张图片作为头像;<br />{<br />   ; "pictureList":[ "url0","url1"] ,<br />   ; "@position ":0,<br />   ; "head()":"get(Collection: pictureList ,Object:@position )"<br />}<br /> ...
174+ "@key ":任意Object | @key 为JSONObject中的关键字 ,作用各不相同,但都不作为查询匹配条件 | ① "@columns ":"id,sex,name",只查询id,sex,name这几个字段;<br /> ② 从pictureList获取第0张图片作为头像;<br />{<br />   ; "pictureList":[ "url0","url1"] ,<br />   ; "@position ":0,<br />   ; "head()":"get(Collection: pictureList ,Object:@position )"<br />}<br /> ...
175175
176176## 对比传统HTTP传输方式
177177
@@ -201,9 +201,9 @@ APIJSON是一种JSON传输结构协议。<br />
201201-------- | ------------ | ------------
202202 User | http://localhost:8080/user?id=1 | http://localhost:8080/{"User":{"id":1}}
203203 User和对应的Work | 分两次请求<br />User: http://localhost:8080/user?id=1 <br />Work: http://localhost:8080/work?userId=1 | http://localhost:8080/{"User":{"id":1} , "Work":{"userId@":"User/id"}}
204- User列表 | http://localhost:8080/user/list?page=1&count=5&sex=0 | http://localhost:8080/{"[ ] ":{"@ page ":1, "@ count ":5, "User":{"sex":0}}}
205- type为1的Work列表,每个Work包括发布者User和前3条Comment | Work里必须有User的Object和Comment的Array<br /> http://localhost:8080/work/list?page=1&count=5&type=1&commentCount=3 | http://localhost:8080/{"[ ] ":{"@ page ":1, "@ count ":5, "Work":{"type":1}, "User":{"workId@":"/Work/id"}, "[ ] ":{"@ count ":3, "Comment":{"workId@":"[ ] /Work/id"}}}}
206- 1个User发布的Work列表,每个Work包括发布者User和前3条Comment | 把以上请求里的type=1改为userId=1 | 有以下几种方法:<br />①把以上请求里的"Work":{"type":1}, "User":{"workId@":"/Work/id"}改为"User":{"id":1}, "Work":{"userId@":"/User/id"}<br /><br />②或这样省去4条重复User<br />http://localhost:8080/{"User":{"id":1} , "[ ] ":{"@ page ":1, "@ count ":5, "Work":{"userId@":"User/id"}, "[ ] ":{"@ count ":3, "Comment":{"workId@":"[ ] /Work/id"}}}}<br /><br />③如果User之前已经获取到了,还可以这样省去所有重复User<br />http://localhost:8080/{"[ ] ":{"@ page ":1, "@ count ":5, "Work":{"userId":1}, "[ ] ":{"@ count ":3, "Comment":{"workId@":"[ ] /Work/id"}}}}
204+ User列表 | http://localhost:8080/user/list?page=1&count=5&sex=0 | http://localhost:8080/{"[ ] ":{"page":1, "count":5, "User":{"sex":0}}}
205+ type为1的Work列表,每个Work包括发布者User和前3条Comment | Work里必须有User的Object和Comment的Array<br /> http://localhost:8080/work/list?page=1&count=5&type=1&commentCount=3 | http://localhost:8080/{"[ ] ":{"page":1, "count":5, "Work":{"type":1}, "User":{"workId@":"/Work/id"}, "[ ] ":{"count":3, "Comment":{"workId@":"[ ] /Work/id"}}}}
206+ 1个User发布的Work列表,每个Work包括发布者User和前3条Comment | 把以上请求里的type=1改为userId=1 | 有以下几种方法:<br />①把以上请求里的"Work":{"type":1}, "User":{"workId@":"/Work/id"}改为"User":{"id":1}, "Work":{"userId@":"/User/id"}<br /><br />②或这样省去4条重复User<br />http://localhost:8080/{"User":{"id":1} , "[ ] ":{"page":1, "count":5, "Work":{"userId@":"User/id"}, "[ ] ":{"count":3, "Comment":{"workId@":"[ ] /Work/id"}}}}<br /><br />③如果User之前已经获取到了,还可以这样省去所有重复User<br />http://localhost:8080/{"[ ] ":{"page":1, "count":5, "Work":{"userId":1}, "[ ] ":{"count":3, "Comment":{"workId@":"[ ] /Work/id"}}}}
207207
208208 服务端对应不同请求的返回结果 | 传统方式 | APIJSON
209209-------- | ------------ | ------------
0 commit comments