Parse and Extract Attributes from JSON

后端 未结 3 2032
终归单人心
终归单人心 2021-01-24 05:16

I have a large JSON file similar to this:

{
   \"data\":[
      {
         \"attribution\":null,
         \"tags\":[
            \"thenight2\"
         ],
               


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-24 05:56

    You can use the Linq features of JSON.net, along with the select token method to get at the data you are looking for:

    String fileContents = System.IO.File.ReadAllText("Z:\\temp\\test.json");
    Newtonsoft.Json.Linq.JObject obj = Newtonsoft.Json.Linq.JObject.Parse(fileContents);
    IList urls = obj["data"].Select(m => (string)m.SelectToken("images.standard_resolution.url")).ToList();
    

提交回复
热议问题