gpt4 book ai didi

iphone - iPhone:如何从JSON请求获取地址?

转载 作者:行者123 更新时间:2023-12-01 17:44:29 24 4
gpt4 key购买 nike

我正在尝试获取此地址=“8198 Snouffer School Rd,Gaithersburg,MD 20879,USA”

从这个json请求,但无法成功完成。

{
"name": "39.165110,-77.168550",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [ {
"id": "p1",
"address": "8198 Snouffer School Rd, Gaithersburg, MD 20879, USA",
"AddressDetails": {
"Accuracy" : 8,
"Country" : {
"AdministrativeArea" : {
"AdministrativeAreaName" : "MD",
"Locality" : {
"LocalityName" : "Gaithersburg",
"PostalCode" : {
"PostalCodeNumber" : "20879"
},
"Thoroughfare" : {
"ThoroughfareName" : "Snouffer School Rd"
}
}
},
"CountryName" : "USA",
"CountryNameCode" : "US"
}
},
"ExtendedData": {
"LatLonBox": {
"north": 39.1661825,
"south": 39.1634846,
"east": -77.1666884,
"west": -77.1693864
}
},
"Point": {
"coordinates": [ -77.1685611, 39.1650977, 0 ]
}
} ]
}

我已经从状态中提取了代码,但是不明白如何提取地址。
NSArray* Status = [(NSDictionary*)[responseString JSONValue] objectForKey:@"Status"];

NSString *code = [Status objectForKey:@"code"];
NSArray* Placemark = [(NSDictionary*)[responseString JSONValue] objectForKey:@"Placemark"];
NSString *address = [Placemark objectForKey:@"address"]; // got error at this line.

最佳答案

这是一个数组,而不是JSON对象。
尝试

NSString *address = [[Placemark objectAtIndex:0] objectForKey:@"address"]]; 

关于iphone - iPhone:如何从JSON请求获取地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10351272/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com