Parsing published data

I have been trying unsuccessfully to parse data I’m publishing to particle.io and then onto adafruit.io using a Webhook. Specifically I’m trying to send ‘value’, ‘lat’ and ‘lon’ to adafruit but the moustache variables are not parsing the published elements.

My publish value looks like this:
{ ‘value’: ‘0’, ‘lat’: ‘43.627125’, ‘lon’: ‘-79.360458’}

When I create a Webhook I am sending via JSON the following:
{
“value”: “{{value}}”,
“lat”: “{{lat}}”,
“lon”: “{{lon}}”
}

These {{}} variables are nil - they don’t parse out of the published data

Note: If I substitute real values instead of the {{}} ones it does work!

Any ideas on what I am doing wrong?
philly

I have been trying unsuccessfully to parse data I’m publishing to particle and then onto adafruit.io using a Webhook. Specifically I’m trying to send a value, lat and lon to adafruit but the moustache variables are not parsing the published elements.

My publish value looks like this:

{ 'value': '0', 'lat': '43.627125', 'lon': '-79.360458'}

When I create a Webhook I am sending via JSON the following:

{
  "value": "{{value}}",
  "lat": "{{lat}}",
  "lon": "{{lon}}"
}

These {{}} variables are nil - they don’t parse out of the published data

Note: If I substitute real values instead of the {{}} ones it does work!

Any ideas on what I am doing wrong?
philly

I have moved your double post of the same question into this thread - don't double post. It just scatters potential answers and ties up resources without additional benefit.


Actually for valid JSON these single quotes must be substituted with double quotes.
In order to add (nested) double quotes to a double-quoted string in C/C++ you'd need to escape them like

  char json[64] = "{ \"value\":\"0\", \"lat\":\"43.627125\", \"lon\":\"-79.360458\" };

THANK YOU so much! I spent hours messing this up - works perfectly now!

Sorry about double posting…

1 Like