0
JSONデータをDictionary
の形式で解析しようとしています。ただし、辞書は別の辞書からの値として配列としてまとめられます。物事を最悪にするために、APIから与えられる唯一のキーは、第3レベルの値(辞書の配列)に対するものです。どのように最初のレベルの辞書内のデータを取得する任意のアイデア?辞書内に埋め込まれた配列内の辞書埋め込みからJSONデータを解析する方法
コードを試みた:
if let valueTripleDictionary = jsonDataDictiony["value"] as? [String : AnyObject]
{
if let valueDoubleDictionary = valueTripleDictionary as? [String : AnyObject]
{
if let valueDictionary = valueDoubleDictionary as? [String : AnyObject]
{
self.busStopCode = valueDictionary["BusStopCode"] as? String
self.roadName = valueDictionary["RoadName"] as? String
self.busStopDescription = valueDictionary["Description"] as? String
self.busStopLatitude = valueDictionary["Latitude"] as? Double
self.busStopLongitude = valueDictionary["Longitude"] as? Double
print(busStopCode)
print(roadName)
print(busStopDescription)
print(busStopLatitude)
print(busStopLongitude)
}
}
}
をこのJSONデータの一部です
["value": <__NSArrayI 0x7fe884d24f00>(
{
BusStopCode = 01012;
Description = "Hotel Grand Pacific";
Latitude = "1.29684825487647";
Longitude = "103.8525359165401";
RoadName = "Victoria St";
},
{
BusStopCode = 01013;
Description = "St. Joseph's Ch";
Latitude = "1.29770970610083";
Longitude = "103.8532247463225";
RoadName = "Victoria St";
}
)
]
ありがとうございます –
ようこそmate :) –