久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='akvZ6'></tfoot>

      <small id='akvZ6'></small><noframes id='akvZ6'>

      <i id='akvZ6'><tr id='akvZ6'><dt id='akvZ6'><q id='akvZ6'><span id='akvZ6'><b id='akvZ6'><form id='akvZ6'><ins id='akvZ6'></ins><ul id='akvZ6'></ul><sub id='akvZ6'></sub></form><legend id='akvZ6'></legend><bdo id='akvZ6'><pre id='akvZ6'><center id='akvZ6'></center></pre></bdo></b><th id='akvZ6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='akvZ6'><tfoot id='akvZ6'></tfoot><dl id='akvZ6'><fieldset id='akvZ6'></fieldset></dl></div>
        <legend id='akvZ6'><style id='akvZ6'><dir id='akvZ6'><q id='akvZ6'></q></dir></style></legend>

          <bdo id='akvZ6'></bdo><ul id='akvZ6'></ul>

        使用 Newtonsoft 將 JSON 反序列化為 .NET 對象(或者可

        Deserializing JSON to .NET object using Newtonsoft (or LINQ to JSON maybe?)(使用 Newtonsoft 將 JSON 反序列化為 .NET 對象(或者可能是 LINQ to JSON?))
        <tfoot id='dogFq'></tfoot>

          • <legend id='dogFq'><style id='dogFq'><dir id='dogFq'><q id='dogFq'></q></dir></style></legend>

              <tbody id='dogFq'></tbody>

            • <small id='dogFq'></small><noframes id='dogFq'>

              <i id='dogFq'><tr id='dogFq'><dt id='dogFq'><q id='dogFq'><span id='dogFq'><b id='dogFq'><form id='dogFq'><ins id='dogFq'></ins><ul id='dogFq'></ul><sub id='dogFq'></sub></form><legend id='dogFq'></legend><bdo id='dogFq'><pre id='dogFq'><center id='dogFq'></center></pre></bdo></b><th id='dogFq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dogFq'><tfoot id='dogFq'></tfoot><dl id='dogFq'><fieldset id='dogFq'></fieldset></dl></div>
                  <bdo id='dogFq'></bdo><ul id='dogFq'></ul>
                  本文介紹了使用 Newtonsoft 將 JSON 反序列化為 .NET 對象(或者可能是 LINQ to JSON?)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我知道有一些關(guān)于 Newtonsoft 的帖子,所以希望這不是重復(fù)...我正在嘗試將 Kazaa 的 API 返回的 JSON 數(shù)據(jù)轉(zhuǎn)換為某種不錯的對象

                  I know there are a few posts about Newtonsoft so hopefully this isn't exactly a repeat...I'm trying to convert JSON data returned by Kazaa's API into a nice object of some kind

                  WebClient client = new WebClient();
                  Stream stream = client.OpenRead("http://api.kazaa.com/api/v1/search.json?q=muse&type=Album");
                  StreamReader reader = new StreamReader(stream);
                  
                  List<string> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(reader.Read().ToString());
                  
                  foreach (string item in list)
                  {
                      Console.WriteLine(item);
                  }
                  
                  //Console.WriteLine(reader.ReadLine());
                  stream.Close();
                  

                  那條 JsonConvert 線只是我最近嘗試的一條……我不太明白,希望通過詢問你們來消除一些步法.我最初試圖將它轉(zhuǎn)換成字典或其他東西......實際上,我只需要在那里獲取幾個值,所以從文檔來看,也許 Newtonsoft 的 LINQ to JSON 可能是一個更好的選擇?想法/鏈接?

                  That JsonConvert line is just the most recent one I was trying...I'm not quite getting it and was hoping to eliminate some footwork by asking you guys. I was originally trying to convert it into a Dictionary or something...and actually, I just need to snag a couple of values in there so judging by the documentation, maybe Newtonsoft's LINQ to JSON might be a better choice? Thoughts/Links?

                  以下是 JSON 返回數(shù)據(jù)的示例:

                  Here is an example of the JSON return data:

                  {
                    "page": 1,
                    "total_pages": 8,
                    "total_entries": 74,
                    "q": "muse",
                    "albums": [
                      {
                        "name": "Muse",
                        "permalink": "Muse",
                        "cover_image_url": "http://image.kazaa.com/images/69/01672812 1569/Yaron_Herman_Trio/Muse/Yaron_Herman_Trio-Muse_1.jpg",
                        "id": 93098,
                        "artist_name": "Yaron Herman Trio"
                      },
                      {
                        "name": "Muse",
                        "permalink": "Muse",
                        "cover_image_url": "htt p://image.kazaa.com/images/54/888880301154/Candy_Lo/Muse/Candy_Lo-Muse_1.jpg",
                        "i d": 102702,
                        "artist_name": "u76e7u5de7u97f3"
                      },
                      {
                        "name": "Absolution",
                        "permalink": " Absolution",
                        "cover_image_url": "http://image.kazaa.com/images/65/093624873365/Mus e/Absolution/Muse-Absolution_1.jpg",
                        "id": 48896,
                        "artist_name": "Muse"
                      },
                      {
                        "name": "Ab solution",
                        "permalink": "Absolution-2",
                        "cover_image_url": "http://image.kazaa.com/i mages/20/825646911820/Muse/Absolution/Muse-Absolution_1.jpg",
                        "id": 118573,
                        "artist _name": "Muse"
                      },
                      {
                        "name": "Black Holes And Revelations",
                        "permalink": "Black-Holes-An d-Revelations",
                        "cover_image_url": "http://image.kazaa.com/images/66/093624428466/ Muse/Black_Holes_And_Revelations/Muse-Black_Holes_And_Revelations_1.jpg",
                        "id": 48813,
                        "artist_name": "Muse"
                      },
                      {
                        "name": "Black Holes And Revelations",
                        "permalink": "Bla ck-Holes-And-Revelations-2",
                        "cover_image_url": "http://image.kazaa.com/images/86/ 825646911486/Muse/Black_Holes_And_Revelations/Muse-Black_Holes_And_Revelations_1 .jpg",
                        "id": 118543,
                        "artist_name": "Muse"
                      },
                      {
                        "name": "Origin Of Symmetry",
                        "permalink": "Origin-Of-Symmetry",
                        "cover_image_url": "http://image.kazaa.com/images/29/825646 912629/Muse/Origin_Of_Symmetry/Muse-Origin_Of_Symmetry_1.jpg",
                        "id": 120491,
                        "artis t_name": "Muse"
                      },
                      {
                        "name": "Showbiz",
                        "permalink": "Showbiz",
                        "cover_image_url": "http: //image.kazaa.com/images/68/825646182268/Muse/Showbiz/Muse-Showbiz_1.jpg",
                        "id": 60444,
                        "artist_name": "Muse"
                      },
                      {
                        "name": "Showbiz",
                        "permalink": "Showbiz-2",
                        "cover_imag e_url": "http://image.kazaa.com/images/50/825646912650/Muse/Showbiz/Muse-Showbiz_ 1.jpg",
                        "id": 118545,
                        "artist_name": "Muse"
                      },
                      {
                        "name": "The Resistance",
                        "permalink": "T he-Resistance",
                        "cover_image_url": "http://image.kazaa.com/images/36/825646864836/ Muse/The_Resistance/Muse-The_Resistance_1.jpg",
                        "id": 121171,
                        "artist_name": "Muse"
                      }
                    ],
                    "per_page": 10
                  }
                  

                  <小時>

                  我做了更多閱讀,發(fā)現(xiàn) Newtonsoft 的 LINQ to JSON 正是我想要的……使用 WebClient、Stream、StreamReader 和 Newtonsoft……我可以點擊 Kazaa 獲取 JSON 數(shù)據(jù),提取 URL,下載文件,并在七行代碼中完成所有操作!我喜歡它.


                  I did some more reading and found Newtonsoft's LINQ to JSON is exactly what I wanted...using WebClient, Stream, StreamReader, and Newtonsoft...I can hit Kazaa for JSON data, extract a URL, download the file, and do it all in like seven lines of code! I love it.

                  WebClient client = new WebClient();
                  Stream stream = client.OpenRead("http://api.kazaa.com/api/v1/search.json?q=muse&type=Album");
                  StreamReader reader = new StreamReader(stream);
                  
                  Newtonsoft.Json.Linq.JObject jObject = Newtonsoft.Json.Linq.JObject.Parse(reader.ReadLine());
                  
                  // Instead of WriteLine, 2 or 3 lines of code here using WebClient to download the file
                  Console.WriteLine((string)jObject["albums"][0]["cover_image_url"]);
                  stream.Close();
                  

                  <小時>

                  這篇文章獲得了如此多的點擊率,我認(rèn)為包含評論中討論的使用"位可能會有所幫助.


                  This post gets so many hits I thought it might be helpful to include the "using" bits that are discussed in the comments.

                  using(var client = new WebClient())
                  using(var stream = client.OpenRead("http://api.kazaa.com/api/v1/search.json?q=muse&type=Album"))
                  using (var reader = new StreamReader(stream))
                  {
                      var jObject = Newtonsoft.Json.Linq.JObject.Parse(reader.ReadLine());
                      Console.WriteLine((string) jObject["albums"][0]["cover_image_url"]);
                  }
                  

                  推薦答案

                  如果你只需要從 JSON 對象中獲取一些項目,我會使用 Json.NET 的 LINQ to JSON JObject 類.例如:

                  If you just need to get a few items from the JSON object, I would use Json.NET's LINQ to JSON JObject class. For example:

                  JToken token = JObject.Parse(stringFullOfJson);
                  
                  int page = (int)token.SelectToken("page");
                  int totalPages = (int)token.SelectToken("total_pages");
                  

                  我喜歡這種方法,因為您不需要完全反序列化 JSON 對象.這對于有時會因缺少對象屬性而讓您感到驚訝的 API 非常有用,例如 Twitter.

                  I like this approach because you don't need to fully deserialize the JSON object. This comes in handy with APIs that can sometimes surprise you with missing object properties, like Twitter.

                  文檔:序列化和反序列化JSON 與 Json.NETLINQ to JSON with Json.NET

                  這篇關(guān)于使用 Newtonsoft 將 JSON 反序列化為 .NET 對象(或者可能是 LINQ to JSON?)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標(biāo)簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)
                  <i id='ENaCl'><tr id='ENaCl'><dt id='ENaCl'><q id='ENaCl'><span id='ENaCl'><b id='ENaCl'><form id='ENaCl'><ins id='ENaCl'></ins><ul id='ENaCl'></ul><sub id='ENaCl'></sub></form><legend id='ENaCl'></legend><bdo id='ENaCl'><pre id='ENaCl'><center id='ENaCl'></center></pre></bdo></b><th id='ENaCl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ENaCl'><tfoot id='ENaCl'></tfoot><dl id='ENaCl'><fieldset id='ENaCl'></fieldset></dl></div>
                • <small id='ENaCl'></small><noframes id='ENaCl'>

                  <legend id='ENaCl'><style id='ENaCl'><dir id='ENaCl'><q id='ENaCl'></q></dir></style></legend>
                  • <bdo id='ENaCl'></bdo><ul id='ENaCl'></ul>

                        <tbody id='ENaCl'></tbody>

                          <tfoot id='ENaCl'></tfoot>
                            主站蜘蛛池模板: 性高潮久久久久久久 | 国产黄色在线观看 | 日韩在线播放视频 | 黑人系列合集h | 亚洲黄色av | 国产成人免费视频 | 久久艹av | 欧美日韩一二三区 | 中文字幕在线视频播放 | 成人毛片网站 | 亚洲h视频 | 五月婷婷中文字幕 | 精品日韩在线观看 | 国产成人三级 | 一级片在线| 国产三级一区 | 啪啪小视频 | 人人澡人人爽 | 国产成人免费视频 | 亚洲毛片av| 国产精品久久久国产盗摄 | 精品久久久久久久久久久久久久久久 | 国产伦精品一区二区三毛 | 成人免费毛片观看 | 精久久久久 | 亚洲三级黄色片 | 黄色小视频在线免费观看 | 日韩精品免费视频 | 香蕉视频在线看 | 国产福利在线 | 中文字幕在线观看网址 | 亚洲一区二区久久 | 国产伦精品一区二区三区视频网站 | 在线视频亚洲 | 色污污| 中文字幕一区二区在线播放 | 成年人网站在线免费观看 | 欧美级毛片 | 在线成人免费视频 | 欧美在线视频观看 | 18精品爽国产白嫩精品 |