ObjectiveBSON icon indicating copy to clipboard operation
ObjectiveBSON copied to clipboard

Odd behavior with blank strings

Open Nonsanity opened this issue 10 years ago • 0 comments

I am parsing a BSON message to an NSDictionary. The BSON has an array like this:

{ Data = "some data"; // all strings are String (not CString) Name = "my name"; Things = ( "thing1", "thing2" ); // an array of Strings },{ Data = "more data"; Name = "another name"; Things = ( "thing3", "thing4" ); }

This works fine converting the BSON to NSDictionary. But when Name is an empty string (not nil—I know that breaks NSDictionary), the "Things" array that comes after it in the BSON structure doesn't get added to the dictionary:

{ Data = "more data"; Name = ""; }

Though the array IS in the BSON. Just changing the Name field to be a space (if it would otherwise be empty) makes the Things array show up again in the output NSDictionary.

Also, if I change the order of the elements so that Things comes before Name, then Things is retained even when Name is an empty string. So order counts here.

Nonsanity avatar Jul 15 '14 19:07 Nonsanity