So I've got this code

String GetTimeString(){        
    strftime(dateArray, 100, dateFormat, getTimeInfo());
    dateString = String(dateArray);
    return dateString;

Being called later like this:

document["Time"] = GetTimeString();

But the resulting object looks like this:

September 12 2020 09:49:04 {"DryBulbTemp":80.762,"WetBulbTemp":72.74606,"Pressure":398.9942,"Humidity":68.32129,"Time":null}

So it behaves this way no matter if I print what comes out of the function immediately before the assignment to the "Time" property. Is ArduinoJson just broken?


ArduinoJson 6 works with fixed memory allocation.

When you create a JsonDocument, you must specify its memory capacity.
If the capacity is too small, some parts will be missing.

The solution is to increase the capacity of the JsonDocument.
Use the ArduinoJson Assistant to know the memory requirements for your project.

| improve this answer | |
  • It is not at all logical that the 'Time' Property would persist but not the value. Nor is the requirement for the allocation to be N+2 whats actually in there. But sure, downvote my question. – A.Rowan Sep 14 at 17:44
  • 1
    I didn't downvote your question. If you believe ArduinoJson is broken, please open an issue on GitHub. If you want to learn how the library works, please read the documentation. – Benoit Blanchon Sep 15 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.