javascript - Serialize Entity Framework Object using Json.Net -


How do I serialize a unit framework object in a JavaScript object (JSON)? I tried to use, but when I try to serialize it, I get the following exception

Exception: Newtonsoft.Json.JsonSerializationException, Message = "Self Referral Loop"

Hitesh

It seems that in relation to cyclical references, the same as the original datacenter serializer The problem is happening. While objects object is quite common while referring to each other in the memory of the object graph, such cyclical references are essentially the result of limitless recursions when the serializer does not specifically have a account for it, it will be serial. In order to deal with cyclical references in general non-binary serial format (XML and JSON are two most popular), some, if any, are established standards.

Microsoft resolved the cyclical problem for Data Contracted SerialIisers .NET 3.5 SP1 by using Ref Synonyms in XML. For my knowledge, there is no such thing for JSON, which may be why JSON.NET is preventing you from sorting your object graph.

I have to make sure that there are only references in your object graph, which are navigable one side of both the routes (not only from parents to child, from child to parent.) Those mothers -The father / child and child / parent are the most common types of cyclical references, it may also be that a lower-level child eventually refers to the root of the graph, causing indirect cyclical graph to be created. (Although they are much less compared to the parent / child's ends.)

After finishing any cyclic reference in your object graph, you should be able to serialize.


Comments