bblanchon / ArduinoJson

📟 JSON library for Arduino and embedded C++. Simple and efficient.
https://arduinojson.org
MIT License
6.72k stars 1.12k forks source link

Sample code for object access seems not to work #538

Closed tius2000 closed 7 years ago

tius2000 commented 7 years ago

This sample code in the API reference seems not to work as success() is not a member of JsonVariant:

JsonVariant error = root["error"];
if (error.success()) 
{
  Serial.println(error.as<char*>());
  return;
}

What type of JsonVariant is returned by JsonObject::get() for not exisiting keys and is there any other method to test it?

bblanchon commented 7 years ago

Hello @tius2000,

I can assure you there is a JsonVariant::success().

Have a look at: https://wandbox.org/permlink/FPFVHsJn2cU2iNX8

You are probably using an old version of ArduinoJson. If not, what is the compiler error?

Regards, Benoit

tius2000 commented 7 years ago

Hi @bblanchon, thank you for your fast response and your great work! You are right, my version is out of date. Perhaps you could add JsonVariant::success() to the this reference?

bblanchon commented 7 years ago

Done.

You're welcome @tius2000, thank you for using ArduinoJson. If you like this probject please add a ⭐️