有没有更好的方法(特别是使用 Linq)在以下 json 字符串中返回 ID 的 List/IEnumerable?
string json = "[{\"Id\":38,\"Name\":\"Albert Einstein\",\"Document\":\"845.803.604-51\"},{\"Id\":102,\"Name\":\"Benoit Mandelbrot\",\"Document\":\"657.322.962-20\"},{\"Id\":86,\"Name\":\"Santos-Dumont Aerospace\",\"CpfCnpj\":\"24.195.152/0001-55\"}]";
目前我有:
Dictionary<string, string>[] deserializedJSON = Ext.Net.JSON.Deserialize<Dictionary<string, string>[]>(json);
List<decimal> idList = new List<decimal>();
foreach (var item in deserializedJSON)
{
foreach (var i in item)
{
if (i.Key == "Id")
idList.Add(Convert.ToDecimal(i.Value));
}
}