0

ArduinoJson version 6
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

ArduinoJson version 6

by theophile on Sat Apr 13, 2019 2:59 am

Hi,

I have difficulties to upgrade my code from ArduinoJson library 5 to 6.

I had a look to the https://arduinojson.org/2018/06/07/version-6-0-0/
But still I beleive, as a novice, I missed something.

MY previous code was :

void decodeJson() {
StaticJsonBuffer<512> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(payload);
if (!root.success()) {
Serial.println("parseObject() failed");
return;
}
isslat=root["iss_position"]["latitude"];
isslon=root["iss_position"]["longitude"];
}

After upgrade :

void decodeJson() {
StaticJsonDocument<512> jsonDocument;
JsonObject& root = jsonDocument.????<JsonObject>(payload);
if (!root.success()) {
Serial.println("parseObject() failed");
return;
}
isslat=root["iss_position"]["latitude"];
isslon=root["iss_position"]["longitude"];

}

I don t know how to include "parse" in the new version ?

Thanks for your help,
Théo

theophile
 
Posts: 9
Joined: Fri Feb 15, 2019 6:25 am

Re: ArduinoJson version 6

by adafruit_support_mike on Mon Apr 15, 2019 3:38 am

According to the page you linked, the .parseObject() method has been replaced by a function named deserializeJson().

There's an example of how to use it on the page, with the function name as the heading.

adafruit_support_mike
 
Posts: 60677
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.