Changing the CDATA SerializeXmlNode Behavior

Apr 10, 2013 at 11:09 PM
Edited Apr 10, 2013 at 11:12 PM
Just some background: I am getting Xml from a Pick database and converting it to json because we would like to move away from Xml. I am writing a new version of software that will expect json from Pick. I am running in to an issue when converting the Xml to Json with Xml containing CDATA.

In that case of
<DESCRIPTION><![CDATA[This is that <font color=\"orange\">HOODIE</font> that everyone wants!]]></DESCRIPTION>
I would like to get back
{ "description": "This is that <font color=\"orange\">HOODIE</font> that everyone wants!" }
Instead of
{ "description" : { "#cdata-sections": "This is that <font color=\"orange\">HOODIE</font> that everyone wants!" }}
I've looked in to overriding the XmlNodeConverter but that thing is a beast and uses a lot of internal utility classes. Is this something that I could do with a custom contract resolver?

The problem really is that I dont know when an Xml node will contain CDATA and ideally I'd like it to be converted to a string rather than an object with a #cdata-section field. I could create a CdataConverter to check whether the json is an object and contains cdata, but then every string in my C# objects would need to use that converter.