Issue 55: JSON deserializing {"a": [ { ] } causes exception to be thrown (and no exception-throwing is documented)
Status:  Fixed
Owner: ----
Closed:  Apr 2009
Reported by joshar...@gmail.com, Apr 24, 2009
What steps will reproduce the problem?

1. Attempt to deserialize the malformed JSON {"a": [ { ] } 

Sample code:

char *badJSON = "{\"a\": [ { ] }";
NSData *badJSONData = [NSData dataWithBytes:badJSON length:13];
NSDictionary *deserialized = [[CJSONDeserializer deserializer]
deserializeAsDictionary:badJSONData error:NULL];


What is the expected output? What do you see instead?

Expected output is that the returned dictionary is nil, and that an
appropriate error object is provided. Instead, an
NSInvalidArgumentException is thrown: '*** -[NSCFArray
insertObject:atIndex:]: attempt to insert nil'.


What version of the product are you using? On what operating system?

TouchJSON 1.0 tag; that is current for TouchJSON, I believe. Running on OS
X, in iPhone Simulator.


Please provide any additional information below.

The workaround of protecting the addObject: call by a check whether the
object is nil works for this particular test case, pending a proper fix.
Apr 24, 2009
Project Member #1 jwight
Thanks Scotty.

Fixed in r301. Unit test added.
Status: Fixed