Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 7 months ago.
Error Parsing json object
I am trying to read a json object from thingspeak The following is my code:
char message[512]; sprintf(message,"GET http://api.thingspeak.com/channels/246738/feeds.json?metadata=true&results=0\r\n"); Read the command
comm->printf("!sending packet length \r\n"); sprintf(cmd, "AT+CIPSEND=%d", strlen(message)+2); esp->SendCMD(cmd); esp->RcvReply(buffer, 5000); comm->printf("response: %s\r\n", buffer);
comm->printf("!sending data packet\r\n"); esp->SendCMD(message); esp->RcvReply(buffer, 7000); comm->printf("response: %s\r\n", buffer); if(strlen(message)!=0) { comm->printf("responce=%s",message); json=&resp[0]; comm->printf("parsing\r\n"); string err = picojson::parse(v, json, json + strlen(json)); if(err.empty()) { field=v.get("field1").get<double>(); comm->printf("field1 value: %f", field); } else { comm->printf("error parsing\r\n"); } }
I am not able to read the full object