I am replacing the SwifyJSON library with Gloss. I am having problems converting my WS response to JSON format. In SwiftyJSON, I did this as follows:
guard let data = response.result.value else {
...
return
}
let jsonData = JSON(data)
My answer is as follows:
[{
"lat": "45.2",
"lon": "-79.38333",
"name": "Sample"
}, {
"lat": "23.43",
"lon": "45.3",
"name": "Sample"
}]
I need to create a JSON object array ([JSON]) from this so that I can use this method:
let jsonArray = ?
guard let destinations = [Destination].fromJSONArray(jsonArray) else
{
...
return
}
I tried:
guard let data = response.result.value as? [(String,AnyObject)] else {
...
return
}
and
guard let data = response.result.value as? [Gloss.JSON] else {
...
return
}
First said: It is not possible to convert a value of type '[(String, AnyObject)]' into the expected type of argument '[JSON]' Second: An initializer for conditional binding must have an optional type, and not “[Destination]"
source
share