-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Problem with nested objects #497
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, I don't know what's wrong, but I think you should simplify your code by removing File myFile = SPIFFS.open("xfile.json", "r");
if (myFile)
{
DynamicJsonBuffer jsonBuffer;
JsonObject& jsona = jsonBuffer.parseObject(myFile);
// ...
}
myFile.close(); I didn't test, but I think it should work as |
Ok, I'll give it a try, But if I provide to parseObject a String like [{"a":1,"b":2},{"a":12,"b":22}] it will able to parse it right ? |
Yes, but this approach uses more memory because you make a full copy of the file in memory. See: |
That is correct, but the array I need will have maximum 10 objects in it and only during the start of the card, so is fine for my project. But you are right about memory. |
I've found that the SPIFFS might have a problem reading data that starts an ends with [], but is not clear for me why this library can not decode an array of JSONs.
My expectation is that after root.success returns TRUE, to iterate over the number of JSONs like
It is possible ? |
Hello Catalin, You need to call See: |
Right! Another case for RTFM :-) |
That was not my point. You're not the first to make that mistake, so I probably missed something as a library author. |
Hi,
I have a issue reading (or writing) a nested JSON on an ESP8266.
What I try to have is a file is [ {"m":1, "h":2} , {"m":10, "h":20} , {"m":100, "h":200} ]
I am using SPIFFS to write the JSON to a file then to read it.
For one object is working fine, but for nested array does not working at all.
Code below:
Not working case:
and working case:
The text was updated successfully, but these errors were encountered: