-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Hi,
I am facing a strange problem. I saved a JSON document into the ESP8266 file system.
Then i load it using this code:
` DynamicJsonDocument jDocLoad(1500);
DynamicJsonDocument jDoc(1500);
if (LittleFS.begin())
{
if (LittleFS.exists("/topRecordings.json"))
{
File cFile = LittleFS.open("/topRecordings.json", "r");
if (cFile)
{
size_t size = cFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
cFile.readBytes(buf.get(), size);
DeserializationError err = deserializeJson(jDocLoad,buf.get());
Serial.println(err.c_str());
serializeJsonPretty(jDocLoad,Serial);
}
cFile.close();
}`
The output of the serializeJsonPretty is this:
{
"maxTempC": 26.54,
"maxTempF": 79.772,
"maxTempTimeStampUTC": "2020-05-19T15:51:44",
"maxTempUNIXTime": 1589903504
}
After, i try to get the maxTempC value, but gives no value and when i put the line jDocLoad.containsKey("maxTempC") it returns FALSE, while the key and value is there which can be seen on the serializeJSonPretty.
What can be the problem?