question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Json Serialization - Ingore property if it's circular reference

See original GitHub issue

Add 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MSRiganticommented, Sep 21, 2017

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.

Developers! Developers! Developers! S. B.

0reactions
exyicommented, Sep 25, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found