I have a JSON object with a specific field whose value is always XML, as follows:
{
...
"XmlValue": "<tag1><etc></etc></tag1>"
...
}
I'm using JSON.Net as the deserializer. I want to make this deserialize to a class like this:
public class ObjectContainingXml
{
...
public XElement XmlValue { get;set; }
...
}
When I try, using JsonConvert.DeserializeObject<ObjectContainingXml>(input), I get this exception: XmlNodeConverter can only convert JSON that begins with an object.
Is there a way to make this natively work in JSON.Net without treating that field as a string and then parsing the field to XML manually?