我想将从API调用接收的对象存储到领域db。
示例Obj:
[
{
"obj_type": "ClassSession",
"_id": "0341bd22-1182-4db3-a667-c8647012741e",
"version": "b2",
"createdOn": "2017-04-01 12:57:39 +0530",
"stage": "SCHEDULED",
"type": "Class Session",
"scheduled_at": "2017-04-01 12:58:39 +0530"
},
{
"obj_type": "Assignment",
"_id": "CmsRsrc2",
"version": "b3",
"name": "Homework",
"type": "HOMEWORK",
"parent": {
"type": "topic",
"id": "parent_id1"
},
"resource_id": "CmsRsrc2",
"assignmentProperty": {}
},
{
"obj_type": "Task",
"_id": "21b72bc0eb3e6d4a1c2bb332593ee19bbc527c92c9249585bed785fc6339e155",
"version": "b0",
"source": {
"type": "T_PROBLEM",
"id": "problem_id1_1"
},
"correctAnswer": 1
},
{
"obj_type": "TaskRecord",
"_id": "ff0748aea74431786a20629ad57676fc84eaa7396b153206540ee9eac1d9bfc8",
"assignmentId": "CmsRsrc2",
"version": "b0/",
"status": "ACTIVE",
"marking_scheme": {},
"sequence": 1
}
]
我有每个obj_type的realm类但我不知道如何从api接收obj,因为从api收到的响应obj不属于任何领域类。
所以我正在寻找一种方法来接收api发送的obj并将其保存到相应的realm类。