When converting JSON to XML encode characters in JSON property names which are not compatible with XML and decode when converting back.
This commit is contained in:
@@ -2554,6 +2554,19 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(@"{""DocumentId"":""13779965364495889899""}", json2);
|
||||
}
|
||||
#endif
|
||||
[Test]
|
||||
public void DeserializeXmlIncompatibleCharsInPropertyName()
|
||||
{
|
||||
var json = "{\"%name\":\"value\"}";
|
||||
|
||||
XmlDocument node = JsonConvert.DeserializeXmlNode(json);
|
||||
|
||||
Assert.AreEqual("<_x0025_name>value</_x0025_name>", node.OuterXml);
|
||||
|
||||
string json2 = JsonConvert.SerializeXmlNode(node);
|
||||
|
||||
Assert.AreEqual(json, json2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeEmptyNodeAndOmitRoot()
|
||||
|
||||
Reference in New Issue
Block a user