Json Serialization - Ingore property if it's circular reference
See original GitHub issueAdd into DotVVM Framework an extension, attribute (or anything else) which forces the use of Newtonsoft.Json.PreserveReferencesHandling setting. Specifies reference handling options for the JsonSerializer. https://www.newtonsoft.com/json/help/html/PreserveReferencesHandlingObject.htm
What about attribute?
[ThisViewModelPreserveReferenceWithSetting( enum Newtonsoft.Json.PreserveReferencesHandling )]
public class DefaultViewModel
{
public ObjectWithCircularReferences MyObject { get; set; }
...
public class DefaultViewModel
{
[ThisPropertyPreserveReferenceWithSetting( enum Newtonsoft.Json.PreserveReferencesHandling )]
public ObjectWithCircularReferences MyObject { get; set; }
...
Thank you.
A question that sometimes drives me hazy: am I or are the others crazy? A. E.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to preserve references in System.Text.Json
Ignore circular references Preserve: It decreases payload size. It creates JSON that is comprehensible for serializers other than System. Text.
Read more >How To Fix Circular Reference Error When Dealing With ...
A circular reference was detected while serializing an object of type 'System.Globalization.CultureInfo'. Description: An unhandled exception ...
Read more >Circular references in JSONSerializer and StackOverflow ...
HasCircularReferences(object ) you can use to detect circular references as well as a ToSafeJson() which basically skips any properties which ...
Read more >JsonSerializer support for circular references · Issue #30496
Object/collection graphs containing circular references (or multiple references to the same entity), can be handled in a few different ways ...
Read more >How to get around the Circular Reference issue with JSON ...
Here is an example custom Jackson JSONSerializer that deals with circular references by serializing the first occurrence and storing a * ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you don 't want, no one will change it. 😃 But it is possible to implement sending data with circular reference to the client. The Data is serializable.
I think it would be fine to have an attribute, that would instruct the serializer to ignore this property it’s a backreference - it would basically behave like
[Bind(None)]
but iff the object is already present in its ancestors.