-
Notifications
You must be signed in to change notification settings - Fork 4
Compose JSON Message
VinceZK edited this page Apr 4, 2020
·
10 revisions
Each entity instance can be represented as a JSON file.
And the JSON is not just an simple data format, but also a message that can be communicated with the server end.
If you want to create a new person instance, just post the message like bellow:
POST http://localhost:3001/api/entity
Accept: */*
Cache-Control: no-cache
Content-Type: application/json
{ "ENTITY_ID": "person",
"person": {"HEIGHT": "170", "GENDER": "male", "FINGER_PRINT": "CA67DE15727C72961EB4B6B59B76743E", "HOBBY":"Reading, Movie, Coding", "TYPE": "employee"},
"r_employee": {"USER_ID": "DH001", "COMPANY_ID":"Darkhouse", "DEPARTMENT_ID": "Development", "TITLE": "Developer", "GENDER":"Male"},
"r_address": [
{"COUNTRY": "China", "CITY":"Shanghai", "POSTCODE": "999999",
"ADDRESS_VALUE":"Room #999, Building #99, XXXX Road #999",
"TYPE": "Current Live", "PRIMARY":1},
{"COUNTRY": "China", "CITY":"Seasaw", "POSTCODE": "888888",
"ADDRESS_VALUE" : "West Valley Lake",
"TYPE": "Born Place", "PRIMARY":0}],
"relationships":[ ]
}
If you want to change the TITLE of an employee(person) from "Developer" to "Architect", then:
PUT http://localhost:3001/api/entity
Accept: */*
Cache-Control: no-cache
Content-Type: application/json
{ "ENTITY_ID": "person",
"INSTANCE_GUID": "2FBE7490E10F11E8A90957FA46F2CECA",
"r_employee": {"action": "update", "USER_ID": "DH001", "TITLE": "Architect"},
}
Want to add a new address? just do it in this way:
PUT http://localhost:3001/api/entity
Accept: */*
Cache-Control: no-cache
Content-Type: application/json
{ "ENTITY_ID": "person",
"INSTANCE_GUID": "2FBE7490E10F11E8A90957FA46F2CECA",
"r_address": [
{"action": "add", "COUNTRY": "China", "CITY":"Shanghai", "POSTCODE": "777777",
"ADDRESS_VALUE":"Building #909, YYYY Road #101",
"TYPE": "Office", "PRIMARY":0}
]
}