ServiceStack.Text.XmlSerializer 有什么问题?
我有对象:
public class weatherdata : IReturn<WashService>
{
public Location location { get; set; }
}
public class Location
{
public string name { get; set; }
public string country { get; set; }
}
尝试像这样反序列化第三方 xml:
var data = ServiceStack.Text.XmlSerializer.DeserializeFromString<weatherdata>("<weatherdata><location><name>Moscow</name><country>RU</country></location></weatherdata>");
data.location.name = 莫斯科。data.location.country 为 NULL;
像这样更改xml:
var data = ServiceStack.Text.XmlSerializer.DeserializeFromString<weatherdata>("<weatherdata><location><country>RU</country><name>Moscow</name></location></weatherdata>");
看看
data.location.name == "Moscow".
data.location.country =="RU";
如果我只更改顺序,为什么会有如此不同的结果?