ArduinoJson: BIG array problem with version 5

Tried your assistant for the following API https://api.binance.com/api/v3/ticker/price on an ESP8266.

Assistant gives the size as 34962 bytes with:

const size_t bufferSize = JSON_ARRAY_SIZE(419) + 419*JSON_OBJECT_SIZE(2) + 14630;

But from the assistant the entries are coming back as empty for:

const char* root_0_symbol = root_[0]["symbol"]; // "ETHBTC"

When I try:

Serial.println(root_0_symbol);

The ESP8266 is not crashing and I get the same results if I just set the json manually rather than via an API call i.e.

const char* json = "[{\"symbol\":\"ETHBTC\",..........................................\"}]";

Any idea why it’s not parsing the json array and not giving any errors?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 34 (8 by maintainers)

Most upvoted comments

From my experience, random failures like that are very often caused by memory fragmentation. Tips: avoid using String objects in the loop, and use a StaticJsonBuffer.

Also, the e19 looks like a chunk size from the chunked Transfer Encoding. I’m surprised that the HTTP library does not handle it. Most of the time, you can get rid of the chunked transfer encoding by using HTTP 1.0 instead of 1.1.

Hi @pieman64,

The JSON document is too big to fit in memory; that’s why the parsing fails. You can confirm this by calling JsonArray::success().

You can solve this problem by parsing each object independently. Please read Can I parse a JSON input that is too big to fit in memory?.

Regards, Benoit