I am trying to parse JSON file generated from ColdFusion server in SerializeJSON format. Is there any specific way to parse the serializeJSON file. It is different than normal Twitter Feed JSON file. How to parse the JSON file in such a format ? I am using SBJSON File for parsing this.
{
"ROWCOUNT": 2,
"COLUMNS": [
"ID",
"TITLE",
"CLASS_START",
"CLASS_END",
],
"DATA": {
"KEY_ID": [
"a11c1a361a38",
"6be127103538"
],
"TITLE": [
"Test ",
"Test2 "
],
"CLASS_START": [
"October, 25 2011 00:00:00",
"October, 26 2011 14:47:00"
],
"CLASS_END": [
"October, 25 2011 00:00:00",
"October, 27 2011 14:47:00"
]
}
}
CODE TO PARSE:
NSString *jsonString = [self jsonFromURLString:urlString];
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSLog(@"dATA : %@", jsonData);
// Parse JSON results with TouchJSON. It converts it into a dictionary.
CJSONDeserializer *jsonDeserializer = [CJSONDeserializer deserializer];
NSError *error = nil;
NSDictionary *resultsDictionary = [jsonDeserializer deserializeAsDictionary:jsonData error:&error];
[self handleError:error];
NSDictionary *dict = [resultsDictionary objectForKey:@"DATA"];
NSLog(@"dict : %@", dict);
for (NSArray *data in dict) {
NSDictionary *title = [data objectAtIndex:0]; /**** Errors here saying [NSCFString objectforkey] not recognised was getting the same error before too****/
NSLog(@"Title : %@", title);
}
Output of my Dictionary:
dict : {
"CLASS_END" = (
"October, 25 2011 00:00:00",
"October, 27 2011 14:47:00"
);
"CLASS_START" = (
"October, 25 2011 00:00:00",
"October, 26 2011 14:47:00"
);
"KEY_ID" = (
"a11c1a361a38",
"6be127103538"
);
TITLE = (
"Test",
"Test2"
)
}