3

I have an XDocument object that comes from business layer, it includes a document property which repeats itself infinitely (God knows why!) with the same values in every repeat and it becomes problematic when I want to serialize this object to JSON using Jil.

Since the document property repeats itself infinitely I get Stackoverflow exception when trying to serialize the object using Serialize method of Jil.

Here is my serialization code (it's part of method that gets an object as input (Data) and do serialization on it then return stringed JSON):

 JSON.Serialize(Data, output,Options.IncludeInherited);

Is there any way that I can prevent my XDocument object from being repeated infinitely?

Or I serialize my object to JSON using Jil without getting Stackoverflow exception?

Newtonsoft has a separate method for XML serialization:

JsonConvert.SerializeXmlNode(xmlNode);

but I couldn't find its equivalent in Jil.

GrandMasterFlush
  • 6,269
  • 19
  • 81
  • 104
Code_Worm
  • 4,069
  • 2
  • 30
  • 35

0 Answers0