What does ReferenceLoopHandling.Ignore in Newtonsoft.json exactly do?

后端 未结 1 1326
轻奢々
轻奢々 2020-12-07 00:14

Can anyone present me a scenario where it can be used. What I understand by ReferenceLoopHandling.Ignore is if you have an object A which references object

相关标签:
1条回答
  • 2020-12-07 00:55

    The documentation on this is available here: http://james.newtonking.com/projects/json/help/html/SerializationSettings.htm

    As of this writing, the behavior is described there as follows (with emphasis mine):

    ReferenceLoopHandling.Error: By default Json.NET will error if a reference loop is encountered (otherwise the serializer will get into an infinite loop).

    ReferenceLoopHandling.Ignore: Json.NET will ignore objects in reference loops and not serialize them. The first time an object is encountered it will be serialized as usual but if the object is encountered as a child object of itself the serializer will skip serializing it.

    ReferenceLoopHandling.Serialize: This option forces Json.NET to serialize objects in reference loops. This is useful if objects are nested but not indefinitely.

    0 讨论(0)
提交回复
热议问题