Tratamiento JSON
NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;
if (!error && httpResp.statusCode == 200) {
if(data){
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data
options:kNilOptions error:&error];
NSLog(@"ReceivedJSON: %@", json);
if (json && !error) {
NSNumber *errorCode = 0;
[PreferenceUtils setLastDataQueryDate:@([[NSDate date] timeIntervalSince1970])];
NSArray *arrayChilds = [json objectForKey:@"members"];
for (id arrayChild in arrayChilds){
NSDictionary* member = [arrayChild objectForKey:@"member"];
LOChild *child = [LOChild mapBasicChild:member];
[[LOApplicationModel sharedInstance].family addObject:child];
}
handler([errorCode intValue],json);
return;
} else {
NSLog(@"Error processing ReceivedJSON: %@", error.localizedDescription);
}
}
} else {
if (!error) {
NSLog(@"Error getting ReceivedJSON, httpResponse: %@", httpResp);
} else {
NSLog(@"Error getting ReceivedJSON, error: %@", error.localizedDescription);
}
}
handler(-1,nil);
{
debug = {
request = {
accept = "*/*";
acceptArray = (
"*/*"
);
ajax = 0;
base = "/";
body = "<null>";
bodyString = "";
company = inmovens;
cookies = (
);
deviceIdentifier = "<null>";
files = (
);
get = {
fromTime = "2016-01-25 12:10";
order = asc;
page = 1;
};
headers = {
Accept = "*/*";
"Accept-Encoding" = "gzip, deflate";
"Accept-Language" = "es-xl";
Authorization = "Bearer dbc32df1e0b0ebf80d9dc1b9af8a13475304be5d";
Connection = "keep-alive";
"Content-Type" = "application/json";
Host = "testrest.locategy.com";
"PHP_AUTH_PW" = "inmovens_pwd";
"PHP_AUTH_USER" = inmovens;
"User-Agent" = "Locategy/4 CFNetwork/758.2.8 Darwin/15.0.0";
};
ip = "83.60.206.43";
length = 0;
method = GET;
post = (
);
proxyIP = "";
referrer = "";
scheme = "HTTP/1.1";
secure = 1;
time = 1453970219;
token = {
0 = dbc32df1e0b0ebf80d9dc1b9af8a13475304be5d;
1 = inmovens;
2 = 196;
3 = "2016-01-29 08:36:59";
4 = all;
5 = "iPhone5c iNMovens";
"access_token" = dbc32df1e0b0ebf80d9dc1b9af8a13475304be5d;
"client_id" = inmovens;
"device_identifier" = "iPhone5c iNMovens";
expires = 1454056619;
scope = all;
"user_id" = 196;
};
type = "application/json";
url = (
members
);
urlOriginal = "members?fromTime=2016-01-25%2012:10&page=1&order=asc";
urlString = members;
userAgent = "Locategy/4 CFNetwork/758.2.8 Darwin/15.0.0";
};
};
members = (
{
member = {
account = {
id = 196;
};
creationTime = "2016-01-27 13:29:26.695224";
email = "demo@demo.com";
id = 191;
lastModificationTime = "2016-01-27 13:29:26.695224";
name = demo;
username = demo;
};
},
{
member = {
account = {
id = 196;
};
creationTime = "2016-01-27 13:56:14.829346";
email = "demo@demo2.com";
id = 192;
lastModificationTime = "2016-01-27 13:56:14.829346";
name = demo2;
username = demo2;
};
}
);
paging = {
limit = 100;
page = 1;
pageCount = 1;
recordCount = 2;
};
}