Json and Circular Reference Exception

Update: Do not try to use NonSerializedAttribute, as the JavaScriptSerializer apparently ignores it. Instead, use the ScriptIgnoreAttribute in System.Web.Script.Serialization. public class Machine { public string Customer { get; set; } // Other members // … } public class Customer { [ScriptIgnore] public Machine Machine { get; set; } // Parent reference? // Other members // … Read more

How did Microsoft create assemblies that have circular references?

I can only tell how the Mono Project does this. The theorem is quite simple, though it gives a code mess. They first compile System.Configuration.dll, without the part needing the reference to System.Xml.dll. After this, they compile System.Xml.dll the normal way. Now comes the magic. They recompile System.configuration.dll, with the part needing the reference to … Read more

How to avoid the “Circular view path” exception with Spring MVC test

@Controller → @RestController I had the same issue and I noticed that my controller was also annotated with @Controller. Replacing it with @RestController solved the issue. Here is the explanation from Spring Web MVC: @RestController is a composed annotation that is itself meta-annotated with @Controller and @ResponseBody indicating a controller whose every method inherits the … Read more

How to serialize DOM node to JSON even if there are circular references?

http://jsonml.org/ takes a shot at a grammar for converting XHTML DOM elements into JSON. An an example: <ul> <li style=”color:red”>First Item</li> <li title=”Some hover text.” style=”color:green”>Second Item</li> <li><span class=”code-example-third”>Third</span> Item</li> </ul> becomes [“ul”, [“li”, {“style”: “color:red”}, “First Item”], [“li”, {“title”: “Some hover text.”, “style”: “color:green”}, “Second Item”], [“li”, [“span”, {“class”: “code-example-third”}, “Third”], ” Item” ] … Read more