i have kind of wired requirement for converting JSON to xml. we have an API that returns the JSON response as below.
{
"status":"Error",
"errorMessages":{
"1001":"Schema validation Error"
}
}
We want to convert this JSON to XML as below using c#
<root>
<status>ERROR</status>
<errorMessages>
<ErrorCode>1001</ErrorCode>
<ErrorDescription>Schema validation Error</ErrorDescription>
</errorMessages>
</root>
The API team is very resistant to change the way there are generating the JSON. So i have to find a way to convert this json to XML.
I am getting the below error when i try to convert
XmlDocument doc = JsonConvert.DeserializeXmlNode(json);
"JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifying a DeserializeRootElementName. Path errorMessages
thanks for the help in advance. :)