Fix Bug when Convert Xml and Xml dont have namespace and one of children have namespace

This commit is contained in:
Ygal
2014-02-20 22:36:35 +02:00
parent 71a91bf34f
commit b81b984448
2 changed files with 24 additions and 3 deletions
@@ -43,6 +43,7 @@ using Newtonsoft.Json.Utilities;
using Newtonsoft.Json.Linq;
#if !NET20
using System.Xml.Linq;
using System.Diagnostics;
#endif
@@ -1909,7 +1910,27 @@ namespace Newtonsoft.Json.Tests.Converters
Assert.AreEqual(xml.notNull.ToString(), w2.notNull.ToString());
}
#endif
[Test]
public void SerializeAndDeserializeXmlWithNamespaceInChildrenRootDontHaveNameSpace()
{
var xmlString = @"<root>
<b xmlns='http://www.example.com/ns'>Asd</b>
<c>AAA</c>
<test>adad</test>
</root>";
var xml = XElement.Parse(xmlString);
var json1 = JsonConvert.SerializeXNode(xml);
var xmlBack = JsonConvert.DeserializeObject<XElement>(json1);
var equals = XElement.DeepEquals(xmlBack, xml);
Assert.IsTrue(equals);
}
}
}
#endif
#endif
@@ -1232,10 +1232,9 @@ namespace Newtonsoft.Json.Converters
if (reader.TokenType != JsonToken.EndObject)
{
manager.PushScope();
DeserializeNode(reader, document, manager, element);
manager.PopScope();
manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
}
}
}
@@ -1394,6 +1393,7 @@ namespace Newtonsoft.Json.Converters
}
else
{
finishedAttributes = true;
}