Dec 14, 2010 at 1:42 PM
Edited Dec 14, 2010 at 1:43 PM
We are using the BSON functionality of Json.NET 3.5 Release 8 in our project and we are very happy with the performance! However, there is a problem with the representation of binary data in the output of this library. According to the BSON specification
at http://bsonspec.org/#/specification there are two subtypes for binary data, 0x00 and 0x02, of which 0x00 is the recommended format.
The BSON specification has the following to say on the 0x02 format:
Old generic subtype - This used to be the default subtype, but was deprecated in favor of \x00. Drivers and tools should be sure to handle \x02 appropriately. The structure of the binary data (the byte* array in the binary non-terminal)
must be an int32 followed by a (byte*). The int32 is the number of bytes in the repetition.
Json.NET uses 0x02 but fails to add the required extra length field to the binary data. This results in errors when trying to read the BSON data with another library like the MongoDB Java driver.
Preferably, Json.NET should start using 0x00 as the binary format, which it is already implicitly doing by omitting the extra length field, and it should support reading the correct 0x02 format. This will probably pose problems with backward compatibility...
Benny van Reeven