I have a Stream sending messages to ubidots and all is working well apart from a parameter I create called location, which should look like this -
[
{
"battery.level": 89,
"battery.voltage": 4,
"location": {"value": 0, "timestamp": 1664178910000, "context": {"lat": 51.2345, "lng": -2.3456}}
}
]
But I am struggling to use an expression to create valid JSON without it being enclosed in "" and treated like a string -
"location":"{ \"value\": 0, \"timestamp\": 1664181267000, \"context\" : {\"lat\": 51.2345, \"lng\": -2.3456}}"
The expression I use is -
'{ "value": 0, "timestamp": ' + timestamp * 1000 + ', "context" : {"lat": ' + position.latitude + ', "lng": ' + position.longitude + '}}'
What am I doing wrong here or should I be using PVM ?