ArduinoJson 5: How did you manage to load from file in to global root object?

ForumCategory: esp8266ArduinoJson 5: How did you manage to load from file in to global root object?
Nishantha asked 3 weeks ago

I am referring to your example and comment:
“As we will reload the current history, we already have the root buffer. No need to create a new one.”

You have created the ‘root’ object in Global declaration:
JsonObject& root = jsonBuffer.createObject();
And created an array:
JsonArray& timestamp = root.createNestedArray(“timestamp”);
When you call load history, you read the data in to an object called ‘root’ expecting that the global root object will get updated.

JsonObject& root = jsonBuffer.parseObject(buf.get());

Does it really work? I mean isn’t is that when you exit function loadHistory() this reference gets destroyed?

I tried to follow your example to reload the history in to the same object declared in global context but the data do not appear in the global object.

Can you clarify whether the example is really working? I used 5.13.5 Library with your example code.

Thanks

Click to rate this post!
[Total: 0 Average: 0]
Do NOT follow this link or you will be banned from the site!
DIY Projects