我使用了“让json =试试JSONSerialization.jsonObject(with:data,options:.mutableContainers)”函数来解析我的json。然后我打印了它。它给了我:
(
{
id = 30;
name = name1;
}
)
然后我尝试使用转换我的json
as? [String: Any]
。但是当我打印时,它给了我零。
为什么给我零钱?
帮助将不胜感激。
答案 0 :(得分:0)
// Your JSON object root: is Array Of Dictionaries
/*
(
{
id = 30;
name = name1;
}
)
*/
if let arrayOfDict = jsonWithObjectRoot as? [[String: Any]] {
for dict in arrayOfDict{
print(dict["name"])
}
}