You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DynamicJsonDocument myClass::readConfigFile() {
// ...
DynamicJsonDocument doc(2048);
deserializeJson(doc, file);
String val = doc["value"];
Serial.print(val); // IT WORKS OOK HERE
return doc;
}
when In another class I call:
DynamicJsonDocument doc = myclassInstance.readConfigFile();
String val = doc["value"];
Serial.print(val); // HERE VAL IS EMPTY
Why val is empty when I try to extract it from a function call?
Thanks
The text was updated successfully, but these errors were encountered:
However, if file is of type char*, deserializeJson() uses the "zero-copy mode" and stores pointers instead of copies, so you must ensure that the input buffer stays in memory.
A simple workaround is to cast to const char* or pass the File instance directly to deserializeJson().
I am trying to read/write SPIFFS in the ESP8266, it seems that closing the file before returning the DynamicJsonDocument solved the problem when reading.
I'm not using char *, I'm storing a DynamicJsonDocument inside SPIFFS,
the document I'm storing contains "String"
Still don't understand why I had the problem since no char* has been used.
Thanks for the answer, for your time and for the awesome work.
Arduino would not be that good without your lib.
Hi all,
I have a class with a function like this
when In another class I call:
Why val is empty when I try to extract it from a function call?
Thanks
The text was updated successfully, but these errors were encountered: