【发布时间】:2014-08-23 20:53:30
【问题描述】:
似乎找不到正确的语法。尝试从 json 文件中获取字典数组:
let books:Array = jsonDict["books"] as Array
//Cannot convert the expression's type Array<$T4> to type StringLiteralConvertible
let books:Array = jsonDict["books"] as Array<Dictionary>
//Reference to generic type "Dicionary" requires arguments in <...>
json 看起来像这样:
{
"id": "1",
"title": "title one",
"books": [
{
"id": "1",
"title": "book title one"
},
{
"id": "2",
"title": "book title two"
}
]
}
【问题讨论】:
-
Array<Dictionary<String, String>>? -
哇,太丑了。不过还好……
标签: arrays json dictionary swift