c#导入Newtonsoft.Json使用Newtonsoft.Json;解析没有key值的数组
1.首先导入Newtonsoft.Json;右键点击项目管理NuGet包点击-浏览-搜索Newtonsoft.Json下载即可,命名空间应用引用using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
string path = @"E:/life-expectancy-table.json";
using (System.IO.StreamReader file=System.IO.File.OpenText(path))
{
using (JsonTextReader reader = new JsonTextReader(file))
{
// JObject o = (JObject) JToken.ReadFrom(reader);
JArray ja = (JArray) JToken.ReadFrom(reader);
for (int i = 0; i < ja.Count; i++)
{
// Console.WriteLine(ja[i][0]);
Console.WriteLine(ja[i][3]);
}
}
}