【发布时间】:2019-08-20 04:24:18
【问题描述】:
我有一个这样的对象:
Account account = new Account
{
Email = "james@example.com",
Active = true,
CreatedDate = new DateTime(2013, 1, 20, 0, 0, 0, DateTimeKind.Utc),
Roles = new List<string>
{
"User",
"Admin"
}
};
用于从 JSON 字符串更新某些属性,例如
string json = @"{
'Active': false,
'Roles': [
'Expired'
]
}";
我用的是newtonsoft的方法:
JsonConvert.PopulateObject(json, account);
我怎样才能从 XML 字符串做同样的事情?
<Account>
<Active>false</Active>
</Account>
谢谢
【问题讨论】: