C# 字符串转成JSON对象 反射获取属性值

将json字符串转成Json对象,获取对应的属性值

// oldtext 是json字符串
List<object> jb = JsonConvert.DeserializeObject<List<object>>(oldtext); //方法一: foreach (JObject item in jb) { foreach (var itm in item.Properties()) { Console.WriteLine(itm.Name); Console.WriteLine(itm.Value); } } //方法二: JArray json = JArray.Parse(oldtext); foreach (JObject items in json) { foreach (var item in items) { Console.WriteLine(item.Key); Console.WriteLine(item.Value); } }
原文地址:https://www.cnblogs.com/youmingkuang/p/15161897.html