I have set up an API that gives a JSON response as follows:
{
"key1": "success",
"key2": {
"int_val": 5,
"str_val": "email",
}
}
I've read this, yet still do not understand how I can access key1 properly. I have tried to decode the data in the transformer through [String : Any], which throws an ambiguous type error: "Type of expression is ambiguous".
So how can I read the response with Siesta in the code below?
service.resource("").request(.post, json: userJSON).onSuccess{ entity in
guard let data = entity.content as? Data else {
return
}
print(data)
}
You can try
Decodable