json - 如何从 nsdictionary swift 获取数组

标签 json swift nsdictionary

我有以下 json 对象。我正在解析 json 并将其存储为字典。现在我想从字典中获取这些数组,但是当我使用 objectForKey("upcomingAppointments") 时它没有给我任何东西

{
  "upcomingAppointments": [],
  "upcomingFollowUps": [],
  "followUps": []
}

DISCTIONARY

最佳答案

试试这个:

var dictionary = //NSDictionary from somewhere...

if let upcomingAppointments = dictionary["upcomingAppointments"] as? NSArray {
    //Process your appointments here.
}

//Same goes for other such json fields.

关于json - 如何从 nsdictionary swift 获取数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29619979/

相关文章:

c# - MVC 3 发送类 JSON

ios - 为什么 UIApplicationMain 函数被命名为类命名风格

ios - 在 swift 扩展中重载 NSDictionary getter

iphone - 何时释放 NSDictionary 实例及其所有值?

php - 使用PHP将mysql数据解析为json

json - Swift - 读取 JSON 文件

java - jackson 自定义类型信息不起作用

ios - 如何解决 unarchiveObject 的弃用问题(withFile :)

ios - 我如何在 View Controller 上保存和调用 UIImage?

ios - 如何将 PFQuery 用于存储为 NSDictionary 值的 PFObject 数组