I am testing SparkJson to see if it will work for my application, and I have hit a snag when I attempt to set String to a JsonObject. For example, the last line of the code listed below does not compile. The compiler states that the rvalue is ambiguous whenever I use a string variable in place of string defined in double quotes.
String gnodeMessage = "";
StaticJsonBuffer<1024> jsonBuffer;
JsonObject& object = jsonBuffer.createObject();
JsonObject& gnode = object.createNestedObject("gnode");
gnode["version"] = "1.0"; // this line compiles, and testing shows it works
gnode["message"] = gnodeMessage; // this line will not compile
I checked the ArduinoJson documentation, and I can’t spot any syntax errors.
Citing: https://bblanchon.github.io/ArduinoJson/example/string/
// You can set a String to a JsonObject or JsonArray:
// WARNING: the content of the String will be duplicated in the JsonBuffer.
root[“sensor”] = sensor;
Can anyone tell this SparkJson noob what I am doing wrong?