Merge branch 'master' of https://github.com/reinaldoarrosi/Newtonsoft.Json into reinaldoarrosi-master
This commit is contained in:
@@ -1160,6 +1160,32 @@ namespace Newtonsoft.Json.Tests.Converters
|
|||||||
""role"": ""Admin1""
|
""role"": ""Admin1""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}";
|
||||||
|
StringAssert.AreEqual(expected, arrayJsonText);
|
||||||
|
|
||||||
|
arrayXml = @"<root>
|
||||||
|
<person id=""1"">
|
||||||
|
<name>Alan</name>
|
||||||
|
<url>http://www.google.com</url>
|
||||||
|
<role json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json"">Admin</role>
|
||||||
|
</person>
|
||||||
|
</root>";
|
||||||
|
|
||||||
|
arrayDoc = new XmlDocument();
|
||||||
|
arrayDoc.LoadXml(arrayXml);
|
||||||
|
|
||||||
|
arrayJsonText = SerializeXmlNode(arrayDoc);
|
||||||
|
expected = @"{
|
||||||
|
""root"": {
|
||||||
|
""person"": {
|
||||||
|
""@id"": ""1"",
|
||||||
|
""name"": ""Alan"",
|
||||||
|
""url"": ""http://www.google.com"",
|
||||||
|
""role"": [
|
||||||
|
""Admin""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}";
|
}";
|
||||||
StringAssert.AreEqual(expected, arrayJsonText);
|
StringAssert.AreEqual(expected, arrayJsonText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2232,6 +2232,30 @@ namespace Newtonsoft.Json.Converters
|
|||||||
{
|
{
|
||||||
foreach (IXmlNode xmlNode in c)
|
foreach (IXmlNode xmlNode in c)
|
||||||
{
|
{
|
||||||
|
#if HAVE_XML_DOCUMENT
|
||||||
|
// ignores the attribute if it is the declaration of namespace "JsonNamespaceUri"
|
||||||
|
var xmlAttribute = xmlNode.WrappedNode as XmlAttribute;
|
||||||
|
|
||||||
|
if (xmlAttribute != null &&
|
||||||
|
xmlAttribute.Prefix.Equals("xmlns", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
xmlAttribute.Value == JsonNamespaceUri)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_XLINQ
|
||||||
|
// ignores the attribute if it is the declaration of namespace "JsonNamespaceUri"
|
||||||
|
var xAttribute = xmlNode.WrappedNode as XAttribute;
|
||||||
|
|
||||||
|
if (xAttribute != null &&
|
||||||
|
xAttribute.IsNamespaceDeclaration &&
|
||||||
|
xAttribute.Value == JsonNamespaceUri)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (xmlNode.NamespaceUri != JsonNamespaceUri)
|
if (xmlNode.NamespaceUri != JsonNamespaceUri)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user