I'm replacing SwifyJSON library with Gloss. I have problems with converting my WS response to JSON format. In SwiftyJSON I did it this way:
guard let data = response.result.value else {
...
return
}
let jsonData = JSON(data)
My response looks like this:
[{
"lat": "45.2",
"lon": "-79.38333",
"name": "Sample"
}, {
"lat": "23.43",
"lon": "45.3",
"name": "Sample"
}]
I need to create from this an array of JSON object ([JSON]) so I can use in 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 one says: Cannot convert value of type '[(String, AnyObject)]' to expected argument type '[JSON]' Second: Initializer for conditional binding must have Optional type, not '[Destination]'