【发布时间】:2017-03-30 08:37:55
【问题描述】:
我解析了一个 json 并得到了一个 JSON 字典。
{
data = (
{
bio = "<null>";
bookmarked = 35;
id = 22;
"last_seen" = {
date = "2017-03-30 14:00:01";
timezone = "Asia/Kolkata";
"timezone_type" = 3;
};
name = "Alex";
username = "Alex";
}
);}
我正在尝试访问用户名和日期。 我试过这样做
let name = userData.value(forKeyPath: "data.username")
print(username)
通过打印这个,我得到一个带有用户名的 __NSSingleObjectArrayI。
Optional(<__NSSingleObjectArrayI 0x6080000120b0>(
Alex
)
)
如何访问它并在其他地方显示?基本上从中提取“Alex”作为字符串?
【问题讨论】:
标签: json swift xcode parsing alamofire