I read this question and don't get answers
I Have multiple JSONs
RouteSequence
{
"checkpoint_id": 145,
"hash": "d5b335dac7c34ba1fd001268b80b21dd",
"is_end": true,
"is_forward_direction": true,
"next_checkpoint_id": 144,
"order": 0,
"path": [
"65.597615 57.153329",
"65.597668 57.153424",
"65.597659 57.153654",
"65.596790 57.153182",
"65.596679 57.153128",
"65.595181 57.152339",
"65.592321 57.150904",
"65.591666 57.150562"
],
"route_id": 87
},
.....
Route
{
"active_from": "2014-03-25",
"active_to": "2024-01-01",
"capacity_type": "",
"checkpoints_ids": [
319,
321,
338,
339,
340,
......
3355,
3375
],
"city_id": 1,
"description": "Областная библиотека - с/о Липовый остров",
"has_cars_for_disabled_persons": false,
"hash": "49587333a979a22d93d09e4313661eaa",
"id": 125,
"name": "156",
"route_type_id": 3
},
.......
Checkpoint
{
"city_id": 2,
"code_number": "09080",
"description": "Большая, 183 в сторону Калинина",
"hash": "cd398f0d4a7baa5a47facb3476394d84",
"id": 1503,
"lat": 56.1307455464724,
"lon": 69.528181378059,
"name": "2 микрорайон",
"routes_ids": [
401,
873
]
},
.........
Entities picture and graph view of entities
I'm using something like this in loop for creating objects from json array:
+ (instancetype)instanceWithEntity:(NSEntityDescription*)entity inContext:(NSManagedObjectContext *)context fromJSONObject:(NSDictionary *)jsonData{
Route *route = [[Route alloc] initWithEntity:entity insertIntoManagedObjectContext:context];
route.id = [jsonData valueForKey:@"id"];
route.capacityType = [jsonData valueForKey:@"capacity_type"];
route.objectHash = [jsonData valueForKey:@"hash"];
route.sequenceDescription = [jsonData valueForKey:@"description"];
route.name = [jsonData valueForKey:@"name"];
return route;
}
And main question: How to handle relationships in these situation. My app at launch start to process this json files for every entity. The reason why i asking is that the my json is not fully nested, it has only arrays of ids of objects from other entities. So how to handle this? For example:
routeSequence.route = ?
this is relationship which refers to JSON RouteSequence. I can't just create here the object, i need to refers to existed object by his id(which can not exist, because this is still not downloaded and parsed)