This project has moved. For the latest updates, please go here.

Deserialize into dictionary

Sep 1, 2008 at 10:09 PM
I'm trying to deserialize a json object that contains embedded objects into a dictionary (string, object). It fails because there is no knowledge of the embedded objects also being of type dictionary. Is there a way to create such a thing?

Here is a sample object I wish to deserialize:
                highlightCode:" ",
                lastReceiptDate:new Date(1207285200000)

Sep 4, 2008 at 3:42 AM
In untyped scenarios like this you can deserialize to a JObject. Call deserialize with a null type argument. JObject implements Dictionary<string, JToken> and children will be values like JArray and JValue (which contains the string, number and date values).
Oct 22, 2008 at 3:42 PM
That works great except for handling of the "lastReceiptDate:new Date(1207285200000)" type entries. I am using the JavaScriptDateTimeConverter for serialization but how do I use this converter when deserializing into a JObject? At present I receive a JToken of type Constructor for incoming dates. I have tried to assign the converter to the serializer before deserializing but it doesn't seem to make any difference. Thoughts?
Oct 27, 2008 at 7:59 AM
I have updated Json.NET. If you build from the latest version of the source in CodePlex it will automatically deserialize date constructors to a date.