如何读取 Swift 中的 JSON 类数据

how to read JSON-like data in Swift

我正在 ios 应用程序上实现 firebase 的云消息传递,我收到了这样的数据变量notification

[AnyHashable("aps"): { alert = { body = Hello; title = "IOS Testing";};"mutable-content" = 1;}]

有谁知道怎么读取里面的数据吗?它看起来很像一个 JSON 文件,但我怎样才能在这里阅读正文?我尝试了通知["aps"]["alert"]["title"] 和通知["aps"].alert.title。两者都无法工作。有人可以帮我吗?谢谢!

guard
    let aps = data[AnyHashable("aps")] as? Dictionary,
    let alert = aps["alert"] as? Dictionary,
    let body = alert["body"] as? String,
    let title = alert["title"] as? String
    else {
        // handle any error here
        return
    }