I’m using latest version of swift sdk
I tried to post a dictionary to a custom service, however the backend can’t parse the data.
The dictionary look like this, with data extracted from a GeoPoint:
let dict : [String: Any] = ["latitude”:geoPoint.latitude, "longitude”:geoPoint.longitude, “categories”: geoPoint.categories, “metadata” : point.metadata as Any ]
When I tried to parse the parameter in cloudcode, I get this: " Unexpected end of JSON input at JSON.parse…"
When I tried to directly print parameter without parsing, only “{” shows up.
If I pass a [[String:Any]] instead of [String: Any] from swift client, cloucode print log shows only “[{”
I suspect this might have something to do with “\” in swift JSONSerialization
If I correctly understand your goal you want to send a dictionary to the server let dict : [String: Any] = ["latitude”:geoPoint.latitude, "longitude”:geoPoint.longitude, “categories”: geoPoint.categories, “metadata” : point.metadata as Any ]
if so, you have to change your business logic a little bit, currently your API Method postPoint expects a String type but instead there must be an Object:
/**
* @param {Object} name
*/
also don’t forget to remove this line var obj = JSON.parse(name); because it’s already an object