Search code examples
jsonmultithreadingperformancexmldocumentdomparser

String XML to JSON conversion in .NET without using XmlDocument


I'm trying to find a more memory efficient solution for converting XML string to JSON string (and vice versa) without using XmlDocument.

Currently, all 3rd party libraries i tried, expects XmlDocument as input.

Before I'm writing my own parser using XmlReader, i was wondering if anyone know of a out of the box solution?


Solution

  • I ended up writing my own thin LightXmlDocument which holds a tree of objects representing xml elements.

    LoadXml method implemented using XmlReader, i'm reading the xml string and building the tree.

    Tested with 10 threads each thread iterating 900 times over different xml sizes:

    enter image description here