Closed jlebright closed 12 years ago
Sorry for the delay responding. I do not get email for these bug reports.
I just tested your JSON here:
NSError *theError = NULL;
NSString *theString = @"{ \
\"siteinfo\": [ \ { \ \"title\": \"My Title\", \ \"address\": \"My Addres\", \ \"phone1\": \"(559) 426-4444\", \ \"welcomeMessage\": \"msg\", \ \"mainLogoUrl\": \"data:image/png;base64, iVBORw0KG...\" \ } \ ] \ }"; NSData theData = [theString dataUsingEncoding:NSUTF8StringEncoding]; // NSData theData = [@"\"\u062a\u062d\u064a\u0627 \u0645\u0635\u0631!\"" dataUsingEncoding:NSUTF8StringEncoding]; theString = [[CJSONDeserializer deserializer] deserialize:theData error:&theError]; theData = [[CJSONSerializer serializer] serializeObject:theString error:&theError]; theString = [[[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding] autorelease]; NSLog(@"%@", theString);
Everything worked as expected.
2011-11-02 08:18:49.172 TouchJSON Demo[29837:707] {"siteinfo":[{"phone1":"(559) 426-4444","welcomeMessage":"msg","title":"My Title","mainLogoUrl":"data:image/png;base64, iVBORw0KG...","address":"My Addres"}]}
You can use various web based JSON lint tools if you think your JSON is badly formatted.
If you still have a problem re-open this bug.
Here is my json: { "siteinfo": [ { "title": "My Title", "address": "My Addres", "phone1": "(559) 426-4444", "welcomeMessage": "msg", "mainLogoUrl": "data:image/png;base64, iVBORw0KG..." } ] }
Of course I truncated the base64 data since it is rather large.
Here is my objective c code: //This was my first attempt, it gave me an error in CJSONScanner.m (theData.Length was null!!!) //NSData theJSONData = jsonResult; //NSError theError = nil; //id theObject = [[CJSONDeserializer deserializer] deserialize:theJSONData error:&theError];
//This is my second attempt:
In this case no error and data.length equals zero in CJSONScanner.m (which seems wrong) an I cannot see anything in dictionary -print dictionary gives me the following:
(gdb) print *dictionary $1 = {