-
Notifications
You must be signed in to change notification settings - Fork 12
TGRESTServer addData:forResource: not working #7
Description
Hi,
I try to load data from a json file using the addData:forResource: method but data are not loaded as object in memory.
.json content
[
{
"id" : 1,
"name" : "place 1"
},
{
"id" : 2,
"name" : "place 2"
}
]
resource definition
TGRESTResource *res = [TGRESTResource newResourceWithName:@"place"
model:@{
@"id": @(TGPropertyTypeInteger),
@"name": @(TGPropertyTypeString)
}];
[[TGRESTServer sharedServer] addResource:res];
[[TGRESTServer sharedServer] addData:[self loadTestData:@"place"] forResource:res];
-
(id)loadTestData:(NSString *)data
{
NSString *pathToJSON = [[NSBundle mainBundle] pathForResource:data ofType:@"json"];
NSData *rawJSON = [NSData dataWithContentsOfFile:pathToJSON];return [NSJSONSerialization JSONObjectWithData:rawJSON options:kNilOptions error:nil];
}
here are the console output
[INFO] GCDWebServer started on port 8888 and reachable at http://192.168.1.69:8888/
2014-06-05 10:28:13.365 xxxxxxx[52038:60b]
Server started with Status: --------
Resources:
place
{
id = 2;
name = 1;
}
Server URL: http://192.168.1.69:8888/
Server Port: 8888
Server Latency Min: 0.00 sec
Server Latency Max: 0.00 sec
Store: InMemory with 1 resources and 0 objects
[INFO] GCDWebServer now reachable at http://RESTEasy_shared.local:8888/
I'm missing something but unable to find.
Thank for your help
loic