| Issue 72: | CJSONDeserializer deserializeAsArray: does not skip whitespace | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Using TouchJSON 1.0.7 Release:
NSError *error = nil;
NSData *json = [NSData dataWithBytes:" [ 123 ]" length:8]; // first character is a whitespace
NSArray *array = [[CJSONDeserializer deserializer] deserializeAsArray:json error:&error];
NSLog(@"array: %@ error:%@", array, error);
Expected:
array: (
123
) error:(null)
Actual:
array: (null) error:Error Domain=CJSONScannerErrorDomain Code=-7 UserInfo=0x3d1d4b0 "Could not scan array. Array not started by a
'{' character."
Also, the error description should be "Array not started by a '[' character." instead of "Array not started by a '{' character."
Workaround:
Using deserialize: instead of deserializeAsArray:
Note:
The same problem probably applies to deserializeAsDictionary: as well.
Jun 4, 2010
Maybe the easiest solution is to remove deserializeAsDictionary:error: and deserializeAsArray:error: from the CJSONDeserializer header. All the deserialize methods return id anyway…
Nov 1, 2010
Fixed in latest github.
Status:
Fixed
|
Labels: TouchJSON