Skip to main content
deleted 47 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 17

Arduino parsing JSON Parsing

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.

Arduino JSON Parsing

I have created an API in ruby on rails and it send the following json response:

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

Am able to successfully hit API and store the response. But when I try to parse it and store data it gives me the error. I have used Arduino JSON library

The Code for parsing the JSON is 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;
  }

and the output on 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 cant parse the data due to the numbers 38 and zero printing  ... I don't know what that is and what it is

P.S:- New to Arduino coding

Arduino parsing JSON

I have created an API in Ruby on Rails and it send the following JSON response:

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

I'm able to successfully hit the API and store the response. But when I try to parse it and store data it gives me an error. I have used the Arduino JSON library.

The code for parsing the JSON is 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("==============");
  if (!root.success()) {
    Serial.println("JSON parsing failed!");
    return false;
  }

And 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 can't parse the data due to the numbers 38 and zero printing... I don't know what that is and what it is.

PS: New to Arduino coding.

I have created an API in ruby on rails and it send the following json response:

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

Am able to successfully hit that apiAPI and store the reponse.response. But when iI try to parse it and store data it gives me the error .. I have used Arduino JSON library

The Code for parsing the JSON is 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; }

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;
  }

and the output on serial monitor is as follows:

In parse fuc 38 {"sun_position":{"altitude":"32.46","azimuth":"223.93"}} 0

============== JSON parsing failed! Disconnect

In parse fuc 38

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}} 0

==============

JSON parsing failed! Disconnect

My guess is it cant parse the data due to the numbers 38 and zero printing ... I dontdon't know what that is and what it is

P.S:- New to ArudinoArduino coding

I have created an API in ruby on rails and it send the following json response:

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

Am able to successfully hit that api and store the reponse.. But when i try to parse it and store data it gives me error .. I have used Arduino JSON library

The Code for parsing the JSON is 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; }

and the output on 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 cant parse the data due to the numbers 38 and zero printing ... I dont know what that is and what it is

P.S:- New to Arudino coding

I have created an API in ruby on rails and it send the following json response:

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

Am able to successfully hit API and store the response. But when I try to parse it and store data it gives me the error. I have used Arduino JSON library

The Code for parsing the JSON is 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;
  }

and the output on 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 cant parse the data due to the numbers 38 and zero printing ... I don't know what that is and what it is

P.S:- New to Arduino coding

Source Link

Arduino JSON Parsing

I have created an API in ruby on rails and it send the following json response:

{"sun_position":{"altitude":"32.46","azimuth":"223.93"}}

Am able to successfully hit that api and store the reponse.. But when i try to parse it and store data it gives me error .. I have used Arduino JSON library

The Code for parsing the JSON is 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; }

and the output on 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 cant parse the data due to the numbers 38 and zero printing ... I dont know what that is and what it is

P.S:- New to Arudino coding