14 KiB
APIJSON
A JSON Transmission Structure Protocal.
You can set any JSON structure and request your server, and the server will return a JSON String with the structure you had set like this:
Request:
{
"[]": { //request an array
"page": 1, //array condition
"count": 2,
"User": { //request an object from the table named User
"sex": 0 //object condition
},
"work": {
"userId": “/User/id” //rely path with default parent path,starts from the same level object's path
},
"Comment[]": { //request an array named Comment
"page": 0,
"count": 3,
"Comment": {
"workId": “[]/Work/id” //full rely path
}
}
}
}
Response:
{
"[]":{
"0":{
"User":{
"picture":"",
"id":"38710",
"sex":"0",
"phone":"1300038710",
"name":"Name-38710",
"head":"http://www.tooopen.com/view/38710.html"
},
"Work":{
"id":470,
"title":"Title-470",
"content":"This is a Content...-470",
"userId":38710,
"picture":"http://www.tooopen.com/view/470.html"
},
"Comment[]":{
"0":{
"Comment":{
"id":4,
"parentId":0,
"workId":470,
"userId":310,
"targetUserId":14604,
"content":"This is a Content...-4",
"targetUserName":"targetUserName-14604",
"userName":"userName-93781"
}
},
"1":{
"Comment":{
"id":22,
"parentId":221,
"workId":470,
"userId":332,
"targetUserId":5904,
"content":"This is a Content...-22",
"targetUserName":"targetUserName-5904",
"userName":"userName-11679"
}
},
"2":{
"Comment":{
"id":47,
"parentId":4,
"workId":470,
"userId":10,
"targetUserId":5477,
"content":"This is a Content...-47",
"targetUserName":"targetUserName-5477",
"userName":"userName-80271"
}
}
}
},
"1":{
"User":{
"picture":"",
"id":"70793",
"sex":"0",
"phone":"1300070793",
"name":"Name-70793",
"head":"http://www.tooopen.com/view/70793.html"
},
"Work":{
"id":170,
"title":"Title-73",
"content":"This is a Content...-73",
"userId":70793,
"picture":"http://www.tooopen.com/view/73.html"
},
"Comment[]":{
"0":{
"Comment":{
"id":44,
"parentId":0,
"workId":170,
"userId":7073,
"targetUserId":6378,
"content":"This is a Content...-44",
"targetUserName":"targetUserName-6378",
"userName":"userName-88645"
}
},
"1":{
"Comment":{
"id":54,
"parentId":0,
"workId":170,
"userId":3,
"targetUserId":62122,
"content":"This is a Content...-54",
"targetUserName":"targetUserName-62122",
"userName":"userName-82381"
}
},
"2":{
"Comment":{
"id":99,
"parentId":44,
"workId":170,
"userId":793,
"targetUserId":7166,
"content":"This is a Content...-99",
"targetUserName":"targetUserName-7166",
"userName":"userName-22949"
}
}
}
}
}
}
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 the path
of APIJSON-Master/table > Start Import > Refresh SCHEMAS, and you'll see the tables were already added.
3.Run Server project with IntellIJ IDEA Ultimate
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 one before run.
5.Operate Client app
Select an APIJSON request to send to server and wait. It will show the result received.
Download Client App
If you haven't config your sever yet, you can use my IP address 192.168.1.107(The last number 7 may be reset to any one from 4 to 7 automatically). But it's not stable because of the interruption of power supply every night from 23:00 to 6:00. I'll boot my computer and start MySQL and APIJSON Server project if I remember. Good lock ^_^
If you have any questions or suggestions about APIJSON, you can send me an e-mail to tommylemon@qq.com.
Welcome star, welcome fork
https://github.com/TommyLemon/APIJSON