I have tried a search… I am trying to get one Ajax call to return multiple variables, instead of many calls. This is a simplified version of what I am trying.
So, I’m trying to create a JSON object within the STRING type of Particle.variable() like this:
char myJSON[255] = "";
snprintf(myJSON, 255, "{\"current\":{\"temp\":%d,\"humidity\":%d,\"dewpoint\":%d}}", int(outdoorTemp), int(relHumidity), int(dewPoint));
strcpy(conditions, myJSON);
and it displays (as valid JSON) on the monitor like this:
but my Ajax call:
function getConditions(){
var condURL = "https://api.spark.io/v1/devices/" + deviceID + "/" + "conditions" + "/?access_token=" + accessToken;
$.getJSON(condURL, function(data) {
alert(JSON.stringify(data));
});
}
when returned, includes all of the escaping:
{"cmd":"VarReturn","name":"conditions","result":"{\"current\":{\"temp\":92,\"humidity\":59,\"dewpoint\":76}}","coreInfo":{"last_app":"","last_heard":"2016-07-31T15:23:58.583Z","connected":true,"last_handshake_at":"2016-07-31T15:22:53.180Z","deviceID":"53ff6c066678505541432367","product_id":0}}
which is of course valid JSON as it treats my pseudo-object as a string (as it should, I guess).
Is there any way to hack this to work?