This may be more a JSON parsing question than a Particle question, but I’ve got a problem. I am sending data using this:
Particle.publish("hello-app-engine", "{\"num1\": 5, \"num2\": 8}");
It shows up in the event as {"num1" : 5, "num2" : 8}
When I send it to a Node.js App Engine project on Google Cloud Platform, and print out
app.post('/sum', (req, res) => {
let num1 = req.body.data.num1;
let num2 = req.body.data.num2;
let sum = num1 + num2;
res.write(`You sent ${JSON.stringify(req.body.data)}\n`);
res.write(`and ${req.body.data.num1}\n`)
res.write(`=======>{"num1":${num1}, "num2":${num2}, "sum":${sum}}`);
res.end();
});
I am getting something very weird:
"You sent \"{\\\"num1\\\": 5, \\\"num2\\\": 8}\"\nand undefined\n=======>{\"num1\":undefined, \"num2\":undefined, \"sum\":NaN}"
So, what’s with the extra backslashes?? I am at a loss, any help would be hugely appreciated.