how to validate JSON string before converting to XML in C#
I will receive an response in the form of JSON string.
We have an existing tool developed in C# which will take input in XML format.
Hence i am converting the JSON string obtained from server using
Newtonsoft.JSON to XML string and passing to the tool.
Problem: When converting JSON response to XML, i am getting an error
"Failed to process request. Reason: The ' ' character, hexadecimal value
0x20, cannot be included in a name."
The above error indicates that the JSON Key contains a space [For Example:
\"POI Items\":[{\"lat\":{\"value\":\"00\"}] which cannot be converted to
XML element.
Is there any approach to identify spaces only JSON key's ["POI Items"] and
remove the spaces in it?
Also suggest any alternative solution so that we needn't change the
existing solution?
Regards, Sudhir
No comments:
Post a Comment