how to parse string array with SwiftyJSON?

后端 未结 4 2136
长情又很酷
长情又很酷 2020-12-13 06:29

Using SwiftyJSON how would I parse the following JSON array into a Swift [String]?

{
    \"array\": [\"one\", \"two\", \"three\"]
}         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 06:54

    You have a Dictionary which holds an Array which holds Strings. When you access a value in the Dictionary, it returns a simple Array of Strings. You iterate it like you would any array.

    for obj in json["array"] {
        println(obj.stringValue)
    }
    

提交回复
热议问题