Downloading and parsing json in swift

前端 未结 9 1209
独厮守ぢ
独厮守ぢ 2020-12-02 05:37

I\'m trying to get the JSON from a website and parse it before putting it inside of an iOS view.

Here\'s my code;

func startConnection(){
        le         


        
9条回答
  •  长情又很酷
    2020-12-02 06:00

    If the original JSON is an array, try this.

    func parseJSON(inputData: NSData) -> Array{
        var error: NSError?
        var boardsDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers, error: &error) as Array
    
        return boardsDictionary
    }
    

提交回复
热议问题