Problems with SparkJson Library

Hey,
i have the following function im mt code that should generate a json that will then be published in the cloud.

#include <SparkJson.h>

String generate_report(String DeviceName, int temp,int humidity, String current_time){
    StaticJsonBuffer<200> jsonBuffer;
    String Output;
    JsonObject& root = jsonBuffer.createObject();
    root["DeviceName"] = DeviceName;
    root["Time"] = current_time;
    
    JsonArray& data = root.createNestedArray("data");
    data.add(temp);
    data.add(humidity);
    
    root.printTo(Serial);
    return Output;
}

and i get the following Error Messages

lib/SparkJson/././JsonVariant.h:77:5: call of overloaded 'set(String&)' is ambiguous
temp_sensor.ino:48:24: no matching function for call to 'ArduinoJson::JsonObject::printTo(String&)'

Does anyone now what to do here? i tried to follow the instructions for the Library given on github. and Even consulted the Original documentation for the Arduino library.
The Documentation states, that i can pass an String as an argument that then gets the JSON data.

Arguments

The destination where the JSON document should be written. It can be either:

a buffer with specified size (the size includes the zero-terminator),
an implementation of Print (like Serial, EthernetClient…),
a String or an std::string.

This looks like the exact same issue:

I think the Problem is, that this port, is pretty old, and doesnt support the kind of behaviour i like to achieve, thankfully the original ArduinoJson library is now available so, im going to use that.

1 Like