My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 72: CJSONDeserializer deserializeAsArray: does not skip whitespace
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Nov 2010


 
Reported by cedric.l...@gmail.com, Jan 13, 2010
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.
Jan 13, 2010
Project Member #1 jwight
Many thanks for filing this.

The problem is that the stripping of the whitespace generally occurs before (and after obviously) those methods 
are performed. To perform them again inside the method would incur a (slight) performance hit for the general 
case.

That said I think you do have a valid bug and will think about a solution.
Status: Accepted
Labels: TouchJSON
Jun 4, 2010
#2 cedric.l...@gmail.com
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
Project Member #3 jwight
Fixed in latest github.
Status: Fixed

Powered by Google Project Hosting