Webhooks with decimal data

Hi,

I created a Webhook to post data to parse.com. That works well except for one tiny detail: decimal numbers are converted to Strings. Is there a way to preserve the double or int type?

My event looks like the this:

{"name":"sensor","data":"{\"status\": 0, \"temp\": 10.46, \"pressure\": 1001.26, \"humidity\": 75.91, \"soil1\": 3290, \"soil2\": 3268, \"soil3\": 3294}","ttl":"60","published_at":"2015-10-15T12:35:08.693Z","coreid":"25002c000447343339373536"}

All the relevant data types of the JSON object are decimals, like status, temp, etc.
The following Webhook is configured to post that data to parse.com:

{
    "eventName": "sensor",
    "deviceid": "25002c000447343339373536",
    "url": "https://api.parse.com/1/classes/Status",
    "requestType": "POST",
    "headers": {
        "X-Parse-Application-Id": "12345678",
        "X-Parse-REST-API-Key": "12345678",
        "Content-Type": "application/json"
    },
    "json": {
        "status": "{{status}}",
        "temperature": "{{temp}}",
        "pressure": "{{pressure}}",
        "humidity": "{{humidity}}",
        "soil1": "{{soil1}}",
        "soil2": "{{soil2}}",
        "soil3": "{{soil3}}",
        "coreid": "{{SPARK_CORE_ID}}"
    },
    "mydevices": true,
    "noDefaults": true
}

Technically that working well, I can see the data on the parse.com dashboard. My only problem are the quotes, for the JSON data send, like:

"status": "{{status}}"

This results in status stored as string at parse.com but I would like to store it as decimal.

"status": {{status}}

This (without the quotes) does not work. Creating the Webhook fails with the following error:

tryParse error [SyntaxError: Unexpected token {]
Please check your .json file for syntax error.

Any idea how this can be solved?

Thx
Markus

This is not possible yet. The Particle cloud software will need to change to make this possible. @Dave has this on his radar.

See these 2 threads for the discussion.

1 Like

Thx @jvanier. I will then use Strings for a will and try to convert them on the parse.com side.

1 Like