183 lines
14 KiB
Markdown
183 lines
14 KiB
Markdown
# APIJSON
|
|
|
|
A Functional JSON Structure Protocal.
|
|
|
|
You can set any JSON structure and your server will return a JSON String with the structure you had set like this:
|
|
|
|
## Request:
|
|
{<br />
|
|
"[]": { //request an array<br />
|
|
"page": 1, //array condition<br />
|
|
"count": 2, <br />
|
|
"User": { //request an object form the table named User<br />
|
|
"sex": 0 //object condition<br />
|
|
},<br />
|
|
"work": {<br />
|
|
"userId": “/User/id” //rely path with default parent path,starts from the same level object's path<br />
|
|
},<br />
|
|
"Comment[]": { //request an array named Comment<br />
|
|
"page": 0,<br />
|
|
"count": 3,<br />
|
|
"Comment": {<br />
|
|
"workId": “[]/Work/id” //full rely path<br />
|
|
}<br />
|
|
}<br />
|
|
}<br />
|
|
}</p>
|
|
|
|
## Response:
|
|
{<br />
|
|
"[]":{<br />
|
|
"0":{<br />
|
|
"User":{<br />
|
|
"picture":"",<br />
|
|
"id":"38710",<br />
|
|
"sex":"0",<br />
|
|
"phone":"1300038710",<br />
|
|
"name":"Name-38710",<br />
|
|
"head":"http://www.tooopen.com/view/38710.html"<br />
|
|
},<br />
|
|
"Work":{<br />
|
|
"id":470,<br />
|
|
"title":"Title-470",<br />
|
|
"content":"This is a Content...-470",<br />
|
|
"userId":38710,<br />
|
|
"picture":"http://www.tooopen.com/view/470.html"<br />
|
|
},<br />
|
|
"Comment[]":{<br />
|
|
"0":{<br />
|
|
"Comment":{<br />
|
|
"id":4,<br />
|
|
"parentId":0,<br />
|
|
"workId":470,<br />
|
|
"userId":310,<br />
|
|
"targetUserId":14604,<br />
|
|
"content":"This is a Content...-4",<br />
|
|
"targetUserName":"targetUserName-14604",<br />
|
|
"userName":"userName-93781"<br />
|
|
}<br />
|
|
},<br />
|
|
"1":{<br />
|
|
"Comment":{<br />
|
|
"id":22,<br />
|
|
"parentId":221,<br />
|
|
"workId":470,<br />
|
|
"userId":332,<br />
|
|
"targetUserId":5904,<br />
|
|
"content":"This is a Content...-22",<br />
|
|
"targetUserName":"targetUserName-5904",<br />
|
|
"userName":"userName-11679"<br />
|
|
}<br />
|
|
},<br />
|
|
"2":{<br />
|
|
"Comment":{<br />
|
|
"id":47,<br />
|
|
"parentId":4,<br />
|
|
"workId":470,<br />
|
|
"userId":10,<br />
|
|
"targetUserId":5477,<br />
|
|
"content":"This is a Content...-47",<br />
|
|
"targetUserName":"targetUserName-5477",<br />
|
|
"userName":"userName-80271"<br />
|
|
}<br />
|
|
}<br />
|
|
}<br />
|
|
},<br />
|
|
"1":{<br />
|
|
"User":{<br />
|
|
"picture":"",<br />
|
|
"id":"70793",<br />
|
|
"sex":"0",<br />
|
|
"phone":"1300070793",<br />
|
|
"name":"Name-70793",<br />
|
|
"head":"http://www.tooopen.com/view/70793.html"<br />
|
|
},<br />
|
|
"Work":{<br />
|
|
"id":170,<br />
|
|
"title":"Title-73",<br />
|
|
"content":"This is a Content...-73",<br />
|
|
"userId":70793,<br />
|
|
"picture":"http://www.tooopen.com/view/73.html"<br />
|
|
},<br />
|
|
"Comment[]":{<br />
|
|
"0":{<br />
|
|
"Comment":{<br />
|
|
"id":44,<br />
|
|
"parentId":0,<br />
|
|
"workId":170,<br />
|
|
"userId":7073,<br />
|
|
"targetUserId":6378,<br />
|
|
"content":"This is a Content...-44",<br />
|
|
"targetUserName":"targetUserName-6378",<br />
|
|
"userName":"userName-88645"<br />
|
|
}<br />
|
|
},<br />
|
|
"1":{<br />
|
|
"Comment":{<br />
|
|
"id":54,<br />
|
|
"parentId":0,<br />
|
|
"workId":170,<br />
|
|
"userId":3,<br />
|
|
"targetUserId":62122,<br />
|
|
"content":"This is a Content...-54",<br />
|
|
"targetUserName":"targetUserName-62122",<br />
|
|
"userName":"userName-82381"<br />
|
|
}<br />
|
|
},<br />
|
|
"2":{<br />
|
|
"Comment":{<br />
|
|
"id":99,<br />
|
|
"parentId":44,<br />
|
|
"workId":170,<br />
|
|
"userId":793,<br />
|
|
"targetUserId":7166,<br />
|
|
"content":"This is a Content...-99",<br />
|
|
"targetUserName":"targetUserName-7166",<br />
|
|
"userName":"userName-22949"<br />
|
|
}<br />
|
|
}<br />
|
|
}<br />
|
|
}<br />
|
|
}<br />
|
|
}</p>
|
|
|
|
|
|
![](https://github.com/TommyLemon/APIJSON/blob/master/picture/apijson_all_pages.jpg?raw=true)
|
|
![](https://github.com/TommyLemon/APIJSON/blob/master/picture/server_idea_log_complex.jpg)
|
|
![](https://github.com/TommyLemon/APIJSON/blob/master/picture/complex_json_cn.jpg?raw=true)
|
|
|
|
## Usage
|
|
|
|
### 1.Download and Unzip APIJSON project
|
|
|
|
Clone or download > Download ZIP > Unzip to a path and remember it.
|
|
|
|
### 2.Import MySQL table files
|
|
|
|
Start MySQLWorkbench > Enter a connection > Click Server menu > Data Import > Select download path</p>
|
|
|
|
of APIJSON-Master/table > Start Import > refresh SCHEMAS, and you'll see the tables were already added.</p>
|
|
|
|
### 3.Run Server project with IntellIJ IDEA
|
|
|
|
If you don't have installed it, please download and install before run.
|
|
|
|
### 4.Run Client project with ADT or Android Studio
|
|
|
|
If you don't have installed any editor above, please download and install before run.
|
|
|
|
### 5.Operate Client app
|
|
|
|
Select a json request to send to server and wait. It will show the result received.
|
|
|
|
|
|
## Welcome star, welcome fork
|
|
|
|
[https://github.com/TommyLemon/APIJSON](https://github.com/TommyLemon/APIJSON)
|
|
|
|
## Download Client App
|
|
|
|
[APIJSONClientApp.apk](http://files.cnblogs.com/files/tommylemon/APIJSON%28ADT%29.apk)
|
|
|
|
# APIJSON, let interfaces go to hell !
|