I feel like i’m getting closer with this but still not quite got it. I’ve played around with your suggestion and can’t quite get it to work. I am using JsonParserGeneratorRK and i believe i need to add 2 values to one key. I have tried this several ways and it’s still not quite right, can someone please explain how i insert two values with one key, the code i have tried so far is:
void createEventPayload(int temp, String location_format, float longi, float lati)
{
JsonWriterStatic<256> jw;
{
char data[256];
//snprintf(data, sizeof(data), "{\"lat\":%f, \"lon\":%f}", lati, longi);
snprintf(data, sizeof(data), "{\"lat\":%f, \"lon\":%f}", lati, longi);
JsonWriterAutoObject obj(&jw);
jw.insertKeyValue("temp", temp);
jw.insertKeyValue("gps", data);
jw.insertKeyValue("lat", lati);
jw.insertKeyValue("lon", longi);
}
Particle.publish("Test_data", jw.getBuffer(), PRIVATE);
The output i am receiving is:
{
"temp":27
"gps":"{"lat":53.065170, "lon":-2.478283}"
"lat":53.06517
"lon":-2.478283
}
I think what i am really after is the output to read
{
"temp":27
"gps": lat:53.065170, lon:-2.478283
"lat":53.06517
"lon":-2.478283
}
Finally - The particle webhook has the below JSON and i am not 100% sure if this needs to be changed?
{
"device": {
"deviceId": "{{{PARTICLE_DEVICE_ID}}}"
},
"measurements": {{{PARTICLE_EVENT_VALUE}}}
}
I am not the greatest coder so any explanation as to what might be going on would be very helpful.