using Newtonsoft.Json;//命名空间的引入:添加Newtonsoft.Json.dll(可以在网上下载)
#region .net中反序列化json对象方法(使用Dynamic)
string json = "[{\"value\":\"test1\",\"score\":90},{\"value\":\"test2\",\"score\":70},{\"value\":\"test3\",\"score\":100}]";
dynamic newValue = JsonConvert.DeserializeObject<dynamic>(json);
for (int i = 0; i < newValue.Count; i++)
{
string value = newValue[i]["value"].Value;
//int score = Convert.ToInt32(newValue[i]["score"].Value);
long score = newValue[i]["score"].Value;
}
#endregion
.net中反序列化json对象方法(使用Dynamic)
最新推荐文章于 2024-07-10 10:02:20 发布