-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
root is destroy in the void loop #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @Ostrochibi, What immediately stands out is that this program abuses of global variables. Regards, PS: If none of this makes sense, please read "The Missing C++ Chapter" in Mastering ArduinoJson. |
Hi @bblanchon , thank you and sorry about my time response. I understand what you say. I modify the code to avoid the global variable. But when i return my root the json exported what not the same than in the function where live the return and the function where i call it. the esp's code:
the serial output: 010f000, len 1384, room 16 The plasticKind have disappear, can you tell me why and how i can solve this pls. Thank you for the time you spend to answer me. |
Hi @Ostrochibi, I'm not sure that this is the solution to your problem, but I can spot something wrong: char* john = "{\"plasticKind\":[{\"plName\":... This variable must be a Please try and tell me how it goes.
Thank you very much for saying that. I often beleive that people have no idea how much time I spend finding bugs in their program, but you proved me wrong ;-) Regards, |
Hi @bblanchon , thank you for this quick answer. So, just look that
and that
the root printed in the two function must be the same no? Instead of that, i have on one side : root in spiff function and on the otherside : In addPlastic the name of the array is replace by an unknow caracter, that is my issue. I suspect my declaration of the object returned, JsonObject& loadPlastic(){}, was not good but i dont know how do it in another way. Maybe i must use a JsonVariant instead because my JsonObject contain a JsonArray? When i think about the time i spend to understand a new example of code, i understand how it can be long and difficult to you, specificly when the code is write by a newbie like me :). |
Hi @bblanchon , I tried to transform my JsonObject in JsonVariant but i have the same issue. Have a good week end. |
Hi @Ostrochibi, I see the problem now: std::unique_ptr<char[]> buf (new char[size]);
file.readBytes(buf.get(), size);
JsonObject& root = jsonBuffer.parseObject(buf.get()); Passing a To fix this issue, just pass the file object to JsonObject& root = jsonBuffer.parseObject(file); See also: Regards, |
Hi Benoit,
First, thank you about the work you offer to us with this library.
I'm facing to an issue i can't resolve by myself. I wanna get back data to the spiff. I get it, i can see it with root.prettyPrintTo(Serial) in the void setup but when i wanna do the same in the void loop there is nothing in except an empty Json than i create in the beginning of the sketch.
Due to that, when i lost my data after each reboot because when i use my add function in the void loop root was empty.
I try to do a second object "root2" and surprise, when i do a root2.prettyPrintTo(Serial) in the void setup it's worked well but when i do the same in the void loop, i have an error root2 was not declared in this scope.
Can you help with that pls?
Version of your library 5.13.1
The scketch:
Have a good day!
The text was updated successfully, but these errors were encountered: