bblanchon / ArduinoJson

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

[Bug:] DeserializationError error -> TooDeep (v6.17) #1424

Closed hasenradball closed 3 years ago

hasenradball commented 3 years ago

Hi Benoit,

with the v 6.17 I get the following error:

Loading configuration...
 >>> ERROR: deserializeJson() failed:  TooDeep

Using the following Code:

bool cConfigIO::readConfig(void) {
  DBG__PRINT(F("\n Loading configuration..."));
  // Open file for reading
  File file = LittleFS.open(filename, "r");
  if (!file) {
    DBG__PRINT(F(">>> ERROR: Failed to open \"config.txt\" file!"));
    return false;
  }
  StaticJsonDocument<512> doc;

  // Deserialize the JSON document
  DeserializationError error = deserializeJson(doc, file);
  if (error) {
    DBG__PRINT(F(">>> ERROR: deserializeJson() failed:"), " ");
    DBG__PRINT(error.f_str());
    return false;
  }
  else
    //serializeJsonPretty(doc, Serial);
    serializeJson(doc, Serial);
    DBG__PRINT("\n");

The code runs with v6.16 Is there an issue with the v6.17?

The serial output looks like:

 >>> Starte Filesystem...
        filesystem mounted successfully!

        FILE: config.txt - 0.33 kB
        FILE: index.html - 6.01 kB
        FILE: script.js - 10.89 kB
        FILE: wordclock.css - 4.59 kB
 Total size: 21.83 kB

 Loading configuration...
 >>> ERROR: deserializeJson() of >config.txt< failed: TooDeep!

 ERROR: read of "config.txt" not sucessful!

 Booting...
 ERROR: keine Konfiguration!

### --- Starte Access Point --- ###
 INFO: Set Access Point Config: true
 INFO: Access Point gestarted
 SSID: Word-Clock IP Adresse: 192.168.55.1
bblanchon commented 3 years ago

Hi @hasenradball,

Thank you for reporting this problem. No, this is not a known bug.

Please provide a reproducible example that works on 6.16 and fails on 6.17. Feel free to use wandbox to share the reprex: 6.16.1, 6.17.0.

Best regards, Benoit

hasenradball commented 3 years ago

As discussed this Issue was introduced by me ... I forgot to save a default Configuration... so the reading of it can not work.