char json[] = "{\"1\":{\"lijn\":\"2 Kraayenstein\",\"min\":5}}";
but this one won't parse:
char json[] = "{\"1\":{\"lijn\":\"2 Kraayenstein\",\"min\":5},\"2\":{\"lijn\":\"2 Leyenburg\",\"min\":18}}";
When I upload my sketch to an Arduino Mega both strings parse fine. Any ideas, anyone?
Here's the complete sketch:
// werkt niet in esp, wel op mega!
#include <ArduinoJson.h>
void setup() {
Serial.begin(9600);
Serial.println("Here we go");
}
void loop() {
StaticJsonBuffer<200> jsonBuffer;
char json[] = "{\"1\":{\"lijn\":\"2 Kraayenstein\",\"min\":5},\"2\":{\"lijn\":\"2 Leyenburg\",\"min\":18}}";
JsonObject& root = jsonBuffer.parseObject(json);
if (!root.success()) {
Serial.println("parseObject() failed");
delay(500);
return;
}
const char* lijn = root["1"]["lijn"];
int mins = root["1"]["min"];
const char* lijn2 = root["2"]["lijn"];
int mins2 = root["2"]["min"];
Serial.println(lijn);
Serial.println(mins);
Serial.println(lijn2);
Serial.println(mins2);
delay(5000);
}