-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Can't fill JsonArray in for loop #10
Comments
Then is a pitfall here.:confused: When you call:
the The bytes of In fact, if you look at the code, you have only declared one To fix this problem, you need to have two
However, I'm very glad you posted that issue because it helped me discover a bug in version 3.1: nested objects in arrays are not working. |
Ah, I understand. I see how my example code can be fixed, thanks to your information. I created that piece of example code to make it easier to understand for you. However, my actual code is a bit different, and I don't see how I can fix that. I create 2 objects of a class called From the class
Then, I try to use this method to construct a larger
I can't see how I should fix this problem. :( If I understand you correctly, the problem now lies in |
The problem is that the
To solve this issue, you could add a
Don't forget the |
Even better, make
|
Your second suggestion looks like a tidy way to code it. I took over your idea, but I can't get it to work. :( It still prints the same object twice, just as before. Is that because the This is what I tried:
I figure that it's not necessary to avoid using a temporary variable if you call
Then I get this error from the Arduino IDE:
I suppose I am still doing something wrong? Thanks for your help so far! |
@bblanchon I have a similar problem, I only see values of the last object. But the code here is outdated I guess? Do you have a suggestion how to solve this in the newest version of ArduinoJson? |
@bblanchon Hi! I have the same problem like ersinpw. I used the builder pattern with no success. The last entry overrides all elements in 'users' field. class JSONBuilder public:
private: Please, may you can help me? Best regards |
(Disclaimer: I'm not at all an expert in C/C++)
I am trying to build a JsonArray in a for loop on an Arduino Mega 2560, iterating through an array. Here is a (somewhat) minimal example of what I'm trying to do.
The expected result is:
However, I get this:
Any idea why I can't construct an JsonArray this way?
The text was updated successfully, but these errors were encountered: