Skip to content

Odd behavior with blank strings #4

@Nonsanity

Description

@Nonsanity

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions