【问题标题】:How to get value from google maps coordinate api responce [duplicate]如何从谷歌地图坐标api响应中获取价值[重复]
【发布时间】:2014-12-13 05:01:08
【问题描述】:

如何在 ios 中从这个响应中获取 id

{
     "kind": "coordinate#jobList",
      "nextPageToken": "1339008280772001",
      "items": [
      {
        "kind": "coordinate#job",      // Job #1
        "id": "2502",
        "state": {
        "kind": "coordinate#jobState",
        "assignee": "mike@example.com",
        "location": {
          "kind": "coordinate#location",
          "lat": 37.421991,
          "lng": -122.08393,
         "addressLine": [
          "1600 Amphitheatre Pkwy, Mountain View CA 94043"
        ]
      },
    "note": [
     "Watch out for androids AND the Tyrannosaurus rex."
    ],
    "title": "Service call",
    "customerName": "Google",
    "customerPhoneNumber": "1-650-253-0000"
   },  

【问题讨论】:

  • 使用NSJSONSerialization

标签: ios google-api


【解决方案1】:

按照建议使用 NSJSONSerialization
您提供的 JSON 不正确,请编写示例代码

/*
Json structure
{
"AD":"Andorra",
"AE":"United Arab Emirates"
}
*/
 NSString *myStr = @"{\"AD\": \"Andorra\", \"AE\": \"United Arab Emirates\"}";
 NSData* cData = [myStr dataUsingEncoding:NSUTF8StringEncoding];

 NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:cData
                                 options:0
                                 rror:NULL];

 NSString *myData = [JSONDictionary objectForKey:@"AD"];

在 myData 中,您将获得安道尔

【讨论】:

  • 关于stackoverflow的规则我应该删除我的答案吗?被 OP 接受,但有些人认为它没用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多