I'm trying to use TouchJSON to deserialize some JSON data coming from the Gowalla API. For some reason if I try to use deserializeAsDictionary:receivedData, it fails with this error every time:
Could not scan dictionary. Dictionary that does not start with '{' character.
The data coming from Gowalla definitely begins with {, however, I'm thinking that there must be some whitespace before it. How do I get rid of it? I tried converting the data to a string then removing whitespaces like this, but it still doesn't work:
NSString *dictionaryString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
[dictionaryString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSData* data = [dictionaryString dataUsingEncoding:NSUTF8StringEncoding];
receivedData = [NSMutableData dataWithData:data];
NSDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:receivedData error:&error];
Anyone have any other ideas...I'm completely stuck.
Thanks,
Sunsu