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
The serialization results incorrect #41
Comments
UPDATE. //
// Step 1: Reserve memory space
//
StaticJsonBuffer<1024> jsonBuffer;
//
// Step 2: Build object tree in memory
//
JsonObject& root = jsonBuffer.createObject();
root["sensor"] = "gps";
root["time"] = 1351824120;
JsonArray& data = root.createNestedArray("data");
//data.add(48.756080, 6); // 6 is the number of decimals to print
//data.add(2.302038, 6); // if not specified, 2 digits are printed
for (int i=0; i<100; i++)
{
JsonObject& jsens = data.createNestedObject();
jsens.add("name", "tizio");
jsens.add("value", i);
}
//
// Step 3: Generate the JSON string
//
root.printTo(Serial); ...the result is the following (290 chars):
I simply underestimated the actual usage of ram. |
Yes, memory usage is almost 4 times bigger in 32-bit than in 8-bit.
In your second last example, it could be:
Also, if you're not working in an embedded environment, you can switch to |
I'll bear in mind, thank you very much for the help. Oh, you were mentioned: |
Hey hey. |
I experience a wrong serialization by using such a snippet:
The resulting JSON is the following:
Is it me?
The text was updated successfully, but these errors were encountered: