Closed briandilley closed 3 months ago
Hello @briandilley,
You must use to<JsonObject>()
, like so:
JsonDocument doc;
this->configCtx.getConfiguration(doc["config"].to<JsonObject>());
Best regards, Benoit
@bblanchon that doesn't work:
JsonDocument doc;
doc["id"] = this->getId();
doc["name"] = this->getName();
doc["weight"] = this->getWeight();
doc["demoable"] = this->isDemoable();
this->configCtx.getConfiguration(doc["config"].as<JsonObject>());
Result:
src/LED_ShowManager.cpp:157:66: error: cannot bind non-const lvalue reference of type 'ArduinoJson::V703PB2::JsonObject&' to an rvalue of type 'ArduinoJson::V703PB2::detail::enable_if<true, ArduinoJson::V703PB2::JsonObject>::type' {aka 'ArduinoJson::V703PB2::JsonObject'}
cannot bind non-const lvalue reference of type
JsonObject&
to an rvalue of typeJsonObject
Somewhere in your code, probably in the definition of getConfiguration()
, there is a JsonObject&
that must be replaced with JsonObject
.
Ok - why should it always be passed by value? Does that not create a copy? The goal here was to pass an object to this function to have the function alter it.
Closing this
Is there a better way of doing this?
The resulting object should look something like this:
I was hoping there'd be a way to create the sub document like so:
or: