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

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

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

        將 JSON 數組解析為 NSDictionary

        Parsing a JSON array into a NSDictionary(將 JSON 數組解析為 NSDictionary)

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

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

              1. <small id='INjmN'></small><noframes id='INjmN'>

                  <tfoot id='INjmN'></tfoot>
                    <tbody id='INjmN'></tbody>
                  本文介紹了將 JSON 數組解析為 NSDictionary的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在使用 Wea??ther Underground API 制作一個應用程序,但在解析與嚴重警報相關的塊時遇到了障礙.JSON 使用具有子鍵值對的鍵值對——這對我來說不是問題,因為我可以從中制作后續的 NSDictionaries——但嚴重警報的條目已被證明是有問題的.見下文:

                  I'm working with the Weather Underground API to make an app and I've hit a snag while parsing the block relating to severe alerts. The JSON uses key-value pairs that have sub key value pairs -- which haven't been a problem for me, as I can make subsequent NSDictionaries out of those -- but the entry for severe alerts has proven problematic. See below:

                  "alerts": [
                      {
                      "type": "WAT",
                      "description": "Flash Flood Watch",
                      "date": "3:13 PM EDT on April 28, 2012",
                      "date_epoch": "1335640380",
                      "expires": "8:00 AM EDT on April 29, 2012",
                      "expires_epoch": "1335700800",
                      "message": "u000A...Flash Flood Watch in effect through Sunday morning...u000Au000AThe National Weather Service in Charleston has issued au000Au000A* Flash Flood Watch for portions of northeast Kentucky... (Note: I trimmed this for length's sake),
                      "phenomena": "FF",
                      "significance": "A"
                      }
                  ]
                  

                  警報"對與我能夠解析的其他對不同,因為它有一個圍繞子值的 [ ] 括號,我不知道如何清除它,所以我可以訪問子值.在我能夠解析的其他示例中,它只有 { } 括號,而不是 { } 和 [ ] 括號.作為參考,括號始終存在——即使沒有惡劣天氣警報……在這種情況下,警報"對返回括號 [ ],不存在子對.

                  The "alerts" pair differs from others I've been able to parse because it has this [ ] bracket surrounding the sub-values and I'm not sure how to clear it so I can access the subvalues. In the other examples I've been able to parse, it only has the { } brackets, and not both the { } and [ ] brackets. For reference, the brackets are always present -- even when there are no severe weather alerts... in that instance the "alerts" pair returns the brackets [ ] with no sub-pairs present.

                  有沒有辦法可以從 NSDictionary 中刪除 [ ] 括號,或者忽略它們?任何建議將不勝感激!

                  Is there a way I can remove the [ ] brackets from the NSDictionary, or otherwise ignore them? Any advice would be appreciated!

                  對于參考和故障排除幫助,以下是我成功解析 JSON 文檔其余部分的方法:

                  For reference and troubleshooting help, here's how I'm parsing the rest of the JSON document successfully:

                  1) 從原始 JSON 創建一個 NSDictionary

                  1) Create an NSDictionary from the raw JSON

                  //Process Weather Call
                  NSError* error;
                  NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
                  

                  2) 為嵌套的 json 對創建后續字典

                  2) Create subsequent dictionaries for nested json pairs

                  NSDictionary *current_observation = [json objectForKey:@"current_observation"];
                  

                  3) 賦值

                  NSString* weather;
                  weather = [current_observation objectForKey:@"weather"];
                  

                  所以最終結果將是一個字符串,上面寫著部分多云"或其他內容,以及許多我沒有顯示的相關天氣值.這些解析成功,因為它們只有范圍括號 {},而不是 [] 括號.

                  So the end result would be a string that says "Partly Cloudy" or something, along with numerous related weather values that I haven't shown. These parse successfully because they only have the scope brackets { }, and not the [ ] brackets.

                  推薦答案

                  括號表示數組中的Json數據.你可以如下解析它

                  The brackets means the Json data there are in an array. You can parse it as following

                  NSArray *alertArray = [json objectForKey:@"alerts"];
                  

                  現在您應該遍歷所有警報并解析它們(在您的情況下它只有 1 個,但在另一個 json 字符串中可能更多):

                  now you should loop through all alerts and parse them (in your case it's only 1, but it could be more in another json string):

                  //parse each alert
                  for (NSDictionary *alert in alertArray ){
                       NSString* description = [alert  objectForKey:@"description"];
                      //etc...
                  }
                  

                  這篇關于將 JSON 數組解析為 NSDictionary的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標已經包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))
                1. <small id='XYuLp'></small><noframes id='XYuLp'>

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

                        • <tfoot id='XYuLp'></tfoot>
                            <bdo id='XYuLp'></bdo><ul id='XYuLp'></ul>
                            主站蜘蛛池模板: 国产91在线播放 | 黄网站在线播放 | 国产精品久久久久久久久久久久久 | 日韩精品一区二区三区视频播放 | 狠狠操网站 | caoporn国产精品免费公开 | 永久www成人看片 | 亚洲精品一区二区 | 亚洲午夜精品 | 亚洲精品18 | 有码在线 | 成人精品一区二区三区四区 | 亚洲精品女人久久久 | 亚洲成av人影片在线观看 | 国产精品欧美一区二区 | 播放一级毛片 | 亚洲精品国产a久久久久久 中文字幕一区二区三区四区五区 | a免费视频 | 精品久久久久久一区二区 | 五月婷婷视频 | 成人h电影在线观看 | 免费观看的av毛片的网站 | 成人在线视频免费观看 | 国产一区二区自拍 | 久久国产欧美日韩精品 | 国产小视频在线 | 久久午夜精品 | 成年人在线观看视频 | 欧美视频 亚洲视频 | 91性高湖久久久久久久久_久久99 | 久久高清国产视频 | 中文精品视频 | 97视频人人澡人人爽 | 国产福利小视频 | 欧美中文字幕 | 中文字幕一区二区三区精彩视频 | 久久美女网 | 91久久精品日日躁夜夜躁欧美 | 午夜精品久久久久久久久久久久久 | 黄色成人国产 | 精品久 |