Fix including array attribute in XML with namespaces (#1880)

This commit is contained in:
James Newton-King
2018-10-15 02:18:44 +13:00
committed by GitHub
parent cbeaa45896
commit 0c6b0748f8
2 changed files with 323 additions and 2 deletions
@@ -1464,7 +1464,7 @@ namespace Newtonsoft.Json.Converters
}
#endregion
#region Reading
#region Reading
/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
@@ -2086,9 +2086,12 @@ namespace Newtonsoft.Json.Converters
if (count == 1 && WriteArrayAttribute)
{
MiscellaneousUtils.GetQualifiedNameParts(propertyName, out string elementPrefix, out string localName);
string ns = string.IsNullOrEmpty(elementPrefix) ? manager.DefaultNamespace : manager.LookupNamespace(elementPrefix);
foreach (IXmlNode childNode in currentNode.ChildNodes)
{
if (childNode is IXmlElement element && element.LocalName == propertyName)
if (childNode is IXmlElement element && element.LocalName == localName && element.NamespaceUri == ns)
{
AddJsonArrayAttribute(element, document);
break;