ESP-MQTT-JSON-Digital-LEDs icon indicating copy to clipboard operation
ESP-MQTT-JSON-Digital-LEDs copied to clipboard

Compiling error 'StaticJsonBuffer' was not declared in this scope

Open jccarey5 opened this issue 6 years ago • 2 comments
trafficstars

When compiling i get an error:

exit status 1 'StaticJsonBuffer' was not declared in this scope

This is the location of the error /********************************** START SEND STATE*****************************************/ void sendState() { StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;

JsonObject& root = jsonBuffer.createObject();

root["state"] = (stateOn) ? on_cmd : off_cmd; JsonObject& color = root.createNestedObject("color"); color["r"] = red; color["g"] = green; color["b"] = blue;

root["brightness"] = brightness; root["effect"] = effectString.c_str();

char buffer[root.measureLength() + 1]; root.printTo(buffer, sizeof(buffer));

client.publish(light_state_topic, buffer, true); }

Is there a fix for this?

jccarey5 avatar Nov 22 '18 03:11 jccarey5

Use the older version of arduinojson, v5x

On Thu, 22 Nov 2018, 03:42 jccarey5 <[email protected] wrote:

When compiling i get an error:

exit status 1 'StaticJsonBuffer' was not declared in this scope

This is the location of the error /********************************** START SEND STATE*****************************************/ void sendState() { StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;

JsonObject& root = jsonBuffer.createObject();

root["state"] = (stateOn) ? on_cmd : off_cmd; JsonObject& color = root.createNestedObject("color"); color["r"] = red; color["g"] = green; color["b"] = blue;

root["brightness"] = brightness; root["effect"] = effectString.c_str();

char buffer[root.measureLength() + 1]; root.printTo(buffer, sizeof(buffer));

client.publish(light_state_topic, buffer, true); }

Is there a fix for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bruhautomation/ESP-MQTT-JSON-Digital-LEDs/issues/103, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0nLmSYeBEZtwUyFQEAJJT82ufJJzkxks5uxh0kgaJpZM4YunOZ .

Joeboyc2 avatar Nov 22 '18 07:11 Joeboyc2

according to ArduinoJson, Migrating from version 5 to 6 on https://arduinojson.org/v6/doc/upgrade/

StaticJsonBuffer has to be changed to StaticJsonDocument and DynamicJsonBuffer to DynamicJsonDocument

please go to the scetch in Arduin ID, find cJsonBuffer and replace cJsonDocument

It'll find and replace 2 codes. Save and pre compile to test. Worked fine for me and now I'm at the newest ArduinoJson lib version

andilge avatar Oct 19 '19 14:10 andilge