DynamicJsonBuffer jsonBuffer(bufferSize);

Any idea why there is no matching function call for the dynamic json buffer? The header file exists in SparkJson. Is this related to the problem that the ArduinoJson library won’t load?

no matching function for call to 'ArduinoJson::DynamicJsonBuffer::DynamicJsonBuffer(const size_t&)'

It would help if you could tell us:
-what device you’re targeting
-what library you’re trying to use
-which IDE you’re using
-which system version you’re using
-what your actual code looks like
-preferably a share link from the web IDE so we can one-click duplicate your project including libraries

1 Like

Sure. The device is a Photon. We are trying to use the SparkJson library (or ArduinoJson if available), using the on-line IDE. Below is the code.


#include <SparkJson.h>
#include "application.h"
#include "HttpClient.h"

const size_t bufferSize = JSON_ARRAY_SIZE(6) + JSON_OBJECT_SIZE(1) + 6*JSON_OBJECT_SIZE(3) + 390;

DynamicJsonBuffer jsonBuffer(bufferSize);
//StaticJsonBuffer<bufferSize> jsonBuffer;

HttpClient http;
http_request_t request;
http_response_t response;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
    //  { "Content-Type", "application/json" },
    //  { "Accept" , "application/json" },
    { "Accept" , "*/*"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL

void tickTock() {
   //Create path for http address
    request.hostname = "";
    request.port = 5000;
    request.path = "/";
    //Get http response and print status, length and response
    http.get(request, response, headers);
    Serial.println(response.status, DEC);
    Serial.println(response.body.length(), DEC);
   // StaticJsonBuffer<bufferSize> jsonBuffer;
    //Convert json String to char*
    int j_length = response.body.length()+1;
    char json[j_length];
    response.body.toCharArray(json, j_length);
    //Create json object
    JsonObject& root = jsonBuffer.parseObject(json);
    if (!root.success()) 
        Serial.println("Parse fail");
        Serial.println("Parse success");
    const char* direction = root["data"][0]["headsign"];
    int arrival = root["data"][0]["time"];
    Serial.println(arrival, DEC);

// create a software timer to get new prediction times every minute
Timer timer(5000, tickTock);
void setup() {

void loop() {

I was able to get your code to compile by using this buffer declaration:

StaticJsonBuffer<500> jsonBuffer;

This also works:

StaticJsonBuffer<bufferSize> jsonBuffer;

When I was using your Dynamic declaration, it wouldn’t compile. Also, you are putting the buffer size in parentheses after the variable name instead of in <> after the variable type. I do not believe you can use the dynamic declaration as as a global variable. You have to use dynamic inside of a function. Perhaps @Moors7 or @ScruffR can confirm that since my C++ skills are not that good.


Usually when you get a error: no matching function message you also get some note: ... message which suggests potential alternatives.

AFAICT, there is no constructor for DynamicJsonBuffer that takes a parameter

That’s exactly the difference between a static and a dynamic buffer.
The static version has a given size, the dynamic one will start of empty and grow as needed.


According to the ArduinoJson assistant it appears that the dynamic buffer is declared globally and takes the buffer size as defined in my code, but maybe I am not reading this correctly or not understanding your suggestions.

I see the discrepancy… perhaps we should ask @bblanchon.

What version of the library are you using and which is ArduinoJson assistant addressing?

BTW, SparkJson might be based on it but it’s not actually ArduinoJson

Hi @stk,

SparkJson is a fork from a very old version of ArduinoJson.
At that time, DynamicJsonBuffer's constructor didn’t take any argument.
I highly recommend that you switch to ArduinoJson 5.13.

I also recommend avoiding the global JsonBuffer.
Please read Why shouldn’t I use a global JsonBuffer?

If you need further assistance, please open an issue on GitHub.


1 Like

@bblanchon, if you’d ever happen to update the Spark/Particle library, could you please add a GitHub link to the library to get to your repo directly from Web IDE.
e.g. like this

Thanks for the info. Do you know what version of ArduinoJson is in the on-line Particle library? I can’t seem to get ArduinoJson library to load using the on-line Particle compiler, to be specific, if I select libraries in the on-line compiler. and then ArduinoJson it just hangs while loading. This seems to be an issue with Particle and not ArduinoJson specifically.

I couldn’t get ArduinoJson to load in Web IDE either… it just sits saying “Loading…”


I was not aware of this problem, thank you very much for reporting it.

I discovered that I uploaded build artifacts with the library.

I published a new revision (5.13.4) without these files and it seems to work fine now.



This is great. The dynamic buffer works perfectly. Thanks.

1 Like