How to send several sensor values to Ubidots

Following the Ubidots Routes tutorial, the JSONata Expression for a single variable such as temperature is as follows and works great.

{
“temperature”: {“value”: body.temp, “timestamp”: when * 1000},
}

How does one send multiple sensor values such as temperature and humidity? I’ve tried the following with some variations, but the route fails.

{
“temperature”: {“value”: body.temp, “timestamp”: when * 1000},
“humidity”: {“value”: body.humidity, “timestamp”: when * 1000},
}

Hi @tonyweil,

What error message are you seeing from Ubidots? Your JSONata expression looks correct to me.

Thanks,
Rob

The following error is in the Notehub.io Route log. The data never gets to Ubidots.

error transforming request: the symbol ‘}’ cannot be used as a prefix operator

The last comma causes this error. You should use:

{
“temperature”: {“value”: body.temp, “timestamp”: when * 1000},
“humidity”: {“value”: body.humidity, “timestamp”: when * 1000}
}

I’m surprised that your first test worked with the comma present at the end…

When I try it in jsonata site ( https://try.jsonata.org/ ) with the comma, I get the error “The symbol “}” cannot be used as a unary operator”.

Also, I don’t know if you did a cut&paste in your message but the double quote is not handled correctly by jasonata because it’s not the correct one: “ vs " .

Thanks, that worked.

The cut and paste quotes explains why I was not able to use JSONata site properly.
Can you explain more about the different double quotes? Apparently this one " comes from typing on the keyboard, and this one “ comes from cutting and pasting in some odd way. What a subtle difference!

I don’t know how you get this character but if you paste it in an ASCII converter, you get 0xE2809C . It seems to be a character using UTF-8 3 bytes encoding.

The other double quotes character in the same ASCII converter is 0x22.