我想使用Alamofire將JSON數據轉換爲Swift中的Dictionary。 我正在嘗試if let dict = response.result.value as? Dictionary<String, AnyObject> { ... }
,不幸的是它不起作用。有什麼建議麼?提前致謝。這是例如打印我response.result.value
使用Alamofire將JSON轉換爲Swift中的字典
Optional(<__NSArrayI 0x6000002893d0>(
{
category = category1;
description = description1;
name = sth1;
id = 1;
price = "213";
type = type1;
},
{
category = category2;
description = description2;
name = sth2;
id = 2;
price = "2133";
type = type4;
},
{
category = category3;
description = description3;
name = sth3;
id = 3;
price = "21334";
type = type5;
}
)
)
爲什麼不使用[ObjectMapper](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwipqdDNzqPRAhWPN1AKHeXAA7wQFggbMAA&url=https%3A%2F %2Fgithub.com%2FHearst-DD%2FObjectMapper&usg = AFQjCNFyUn25wAdc4YI3J79e10bh5EsWTQ)? –