This project has moved and is read-only. For the latest updates, please go here.

Serializing System.Guid to BsonBinaryType.Uuid

Nov 15, 2011 at 1:07 PM

I notice that the JSON.NET code it has the BsonBinaryType.Uuid defined, but it isn't used anywhere.  The MongoDB C# driver seems to serialize GUIDs to this sub-type (looking at the documentation).

Is it possible to make JSON.NET serialize System.Guid to this type, and therefore automatically deserialize back to a System.Guid?  At the moment if I serialize an object containing a GUID it will serialize it as a string, and when I deserialize my object to IDictionary<string, object> I get back a string rather than a System.Guid for that property.

Alternatively, is there any other way to get a serialized System.Guid to automatically deserialize when requesting an IDictionary<string, object>?