Hello i have this code that is not working when i reach the parsing fucntion.
It tells me alway "parseObject() failed".
the value of Json String variable is :
{"id_operazione":"21871","id_circolo":"38","id_utente":"3","ora_prenotata":"2017-02-17 14:00:00","importo":"15","annullata":"0","campo":"1","data_operazione":"2017-01-21 20:45:56","testo_operazione":"","id_utente_2":"0","id_utente_3":"0","id_utente_4":"0","tipo_prenotazione":"0"}
Can you help me?
StaticJsonBuffer<300> jsonBuffer;
bool checkJson(String Campo)
{
while (client.connected() || client.available()) //connected or data available
{
char c = client.read(); //gets byte from wifi buffer
c = utf8ascii(c); // convert from utf8
///get JSON
if (c == '{') {
begin = true;
}
if (begin) response += (c);
if (c == '}') {
break;
}
delay(1);
}
Serial.println(response);
//deserializzo
char jsonText[response.length()];
response.toCharArray(jsonText,response.length());
JsonObject& root = jsonBuffer.parseObject(jsonText);
if (!root.success())
{
Serial.println("parseObject() failed");
client.flush();
client.stop();
Serial.println("-------------------");
return false;
}
TTOre_data data;
data.id_operazione = root["id_operazione"];
}