8000 Key and value is present but returns NULL · Issue #1273 · bblanchon/ArduinoJson · GitHub
[go: up one dir, main page]

Skip to content
Key and value is present but returns NULL #1273
@vaz83

Description

@vaz83

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0