I'm almost successfully able to GET a json blob and print it to the console. It seems to be failing on some string fields I am guessing because of the length. Any thoughts/ideas/suggestions to make this work?

The requested json blob (I can see this entire string from the console, it is spaced out here for readability). The entire length of the original string happens to be 597 characters.

            "summary":"QM: API Timeout Error on Checkout "
            "summary":"Search \"term\" options - broken in loader see sproc"

The code I'm using to fetch this json object reduced as much as possible:

JsonRequest request(2048);
//...snip...// (inside JsonRequest object)
WiFiClientSecure *client = new WiFiClientSecure;
HTTPCliernt download_client;
download_client.begin(*client, url);
download_client.collectHeaders(headerKeys, 5);
download_client.setUserAgent( HARDWARE_NAME );
int httpCode = download_client.GET();
if(httpCode == HTTP_CODE_OK) 
    String result = download_client.getString();
    dsError = deserializeJson(*this, (uint8_t*) (result.c_str()) );  //this refers to this object which is the JsonRequest
        return true;
(outside JsonRequest object, request is a deseralized `SpiRamJsonDocument` )

int total = request["total"].as<int>();                         //working: 2
int startAt = request["startAt"].as<int>();                     //working: 0
int maxResults = request["maxResults"].as<int>();               //working: 50
int totalRecords = total + startAt;
for(; startAt < totalRecords && maxResults > 0; startAt++, maxResults--) 
    log_i("%s: %s - %s"
        ,request["issues"][startAt]["key"].as<String>()                 //working: BP-4349
        ,request["issues"][startAt]["fields"]["summary"].as<String>()   //broken? (garbage string)
        ,request["issues"][startAt]["self"].as<String>()                //broken? (garbage string)


I don't know why some strings worked and some did not. I assume that the length of the string is the problem ? How would you suggest I retrieve the longer strings ? How do I know when the length dictates the use of .as<String>() vs something else?

  • Maybe it chokes on the escaped quotes (\") within the last string? May 10 at 15:29
  • @EdgarBonet thanks for the thought. I tried removing the quotation marks (from the json result) this did not change the result. May 10 at 17:07

1 Answer 1


Turns out there is a arduino json troubleshooter specifically for this type of issue here: https://arduinojson.org/v6/troubleshooter/ wow awesome. If you are having an similar issue I would start there.

This didn't fix my problem, for myself if I cast the types to const char * meaning

const char* x = request["issues"][startAt]["self"].as<const char *>()
log_i("%s", x);

this worked every time for every string

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.