Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: 'const char* ArduinoJson::JsonVariantBase<TImpl>::asString() const [with TImpl = ArduinoJson::JsonObjectSubscript<const char*>]' is deprecated #12

Closed
minida28 opened this issue Apr 23, 2017 · 1 comment

Comments

@minida28
Copy link

minida28 commented Apr 23, 2017

Got below warnings during compilation:

sketch\FSWebServerLib.cpp: In member function 'bool AsyncFSWebServer::loadHTTPAuth()':

sketch\FSWebServerLib.cpp:363:51: warning: 'const char* ArduinoJson::JsonVariantBase<TImpl>::asString() const [with TImpl = ArduinoJson::JsonObjectSubscript<const char*>]' is deprecated (declared at D:\minida28\Dropbox\Arduino\Sketch\libraries\ArduinoJson/include/ArduinoJson/Deserialization/../JsonVariantBase.hpp:36): use as<char*>() instead [-Wdeprecated-declarations]

     _httpAuth.wwwUsername = json["user"].asString();

                                                   ^

sketch\FSWebServerLib.cpp:364:51: warning: 'const char* ArduinoJson::JsonVariantBase<TImpl>::asString() const [with TImpl = ArduinoJson::JsonObjectSubscript<const char*>]' is deprecated (declared at D:\minida28\Dropbox\Arduino\Sketch\libraries\ArduinoJson/include/ArduinoJson/Deserialization/../JsonVariantBase.hpp:36): use as<char*>() instead [-Wdeprecated-declarations]

     _httpAuth.wwwPassword = json["pass"].asString();

As advised by the warning above, I simply change on these lines on FSWebServerLib.cpp file:

    _httpAuth.wwwUsername = json["user"].asString();
    _httpAuth.wwwPassword = json["pass"].asString();

to this

    _httpAuth.wwwUsername = json["user"].as<char*>();
    _httpAuth.wwwPassword = json["pass"].as<char*>();

No more warnings.

I was on:

  • Arduino IDE 1.8.1
  • FSBrowserNG master
  • ArduinoJSON 5.8.3

Maybe not really an issue but I just don't know if there will be side effects to this library by doing the changes above.

Thanks for the great library though!

@gmag11
Copy link
Owner

gmag11 commented May 1, 2017

Thank you for the info. Solved

@gmag11 gmag11 closed this as completed May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants