I am putting my payload but it is coming like this:
{
"mode": "sync",
"messageType": "57cd765743f3f9c473d5",
"messages": [{
"Humidity": "99.1",
"Temperature": "99.2",
"Brightness": "99.3",
"Timestamp": "1999999999"
}]
}
When should it go like this:
{
"mode": "sync",
"messageType": "57cd765743f3f9c473d5",
"messages": [{
"Humidity": 25.7,
"Temperature": 21.5,
"Brightness": 13.0,
"timestamp": 1413100000
}]
}
Code:
//Creates a new Messaging.Message Object and sends it to the HiveMQ MQTT Broker
var publish = function(payload, topic, qos) {
mensagem.Humidity = document.getElementById("humidity").value;
mensagem.Temperature = document.getElementById("temperature").value;
mensagem.Brightness = document.getElementById("brightness").value;
mensagem.Timestamp = document.getElementById("timestamp").value;
pl.messages = new Array();
pl.messages[0] = mensagem;
console.log(JSON.stringify(pl));
//Send your message (also possible to serialize it as JSON or protobuf or just use a string, no limitations)
var message = new Messaging.Message(payload);
message.destinationName = topic;
message.qos = 2;
//message.retained = true;
client.send(message);
}
How do I clean up those "" left over in my payload?