I have created an API in rubyRuby on railsRails and it send the following jsonJSON response:
{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}
AmI'm able to successfully hit the API and store the response. But when I try to parse it and store data it gives me thean error. I have used the Arduino JSON library.
The Codecode for parsing the JSON isis as follows:
bool parseSunPosData(char* content, SunPosData* sunPos) {
StaticJsonBuffer<JSONBUFFER_SIZE> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(content);
Serial.println("In parse fuc");
Serial.println(content);
// Serial.println(root);
Serial.println("==============");
if (!root.success()) {
Serial.println("JSON parsing failed!");
return false;
}
andAnd the output on the serial monitor is as follows:
In parse fuc 38
{"sun_position":{"altitude":"32.46","azimuth":"223.93"}} 0
==============
JSON parsing failed! Disconnect
My guess is it cantcan't parse the data due to the numbers 38 and zero printing ... I don't know what that is and what it is.
P.SPS:- New to Arduino coding.