deserialize circular references

Mar 7, 2013 at 1:00 PM
Dear,

I'm trying to deserialize this json-string:
{"$id":"1","ID_Dummy":1,"Name":"Hello","ID_Dummy2":2,"DummyTable2s":[{"$id":"2","ID_Dummy2":2,"Name2":"LOLWAT","ID_Dummy":1,"DummyTables":[{"$ref":"1"},{"$id":"3","ID_Dummy":3,"Name":"Name","ID_Dummy2":2,"DummyTable2s":[{"$id":"4","ID_Dummy2":4,"Name2":"HAHAHA","ID_Dummy":3,"DummyTables":[],"DummyTable":{"$ref":"3"}}],"DummyTable2":{"$ref":"2"}},{"$id":"5","ID_Dummy":5,"Name":"Veronique","ID_Dummy2":2,"DummyTable2s":[],"DummyTable2":{"$ref":"2"}}],"DummyTable":{"$ref":"1"}}],"DummyTable2":{"$ref":"2"}}
I got this result by these settings:
            config.Formatters.JsonFormatter.MaxDepth = 2;
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None;
Now I don't manage to get this json deserialized again to the same linq-classes as they were before serializing..

I'm trying to deserialize by this line:
DummyTable user = JsonConvert.DeserializeObject<DummyTable>(urltxt, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Serialize, Formatting = Formatting.None, NullValueHandling = NullValueHandling.Ignore });
What am I doing wrong?
May 7, 2014 at 1:31 AM
I also have the same problem. Is there a solution to this ?