I tried a lot of versions now, but I always get errors like here:
error: invalid types 'ArduinoJson6172_91::DynamicJsonDocument* {aka ArduinoJson6172_91::BasicJsonDocument<ArduinoJson6172_91::DefaultAllocator>*}[const char [3]]' for array subscript
My assumptions was that it can't be sooo difficult to set the DynamicJson to a class member
Your challenge is the you don't dereference the right thing. Check the C++ Operator Precedence
when you write
*_configJson["jsonkey"]
the compiler tried to get
_configJson["jsonkey"]
as a pointer and then applies the * operator to get its content.
that's not what you want to do: you need to first dereference your pointer and then apply the [] operator. Using parenthesis helps with this: [color=red]([/color]*_configJson[color=red])[/color]["jsonkey"]
this might help
#include <ArduinoJson.h>
DynamicJsonDocument* _configJson;
void setup() {
Serial.begin(115200);
_configJson = new DynamicJsonDocument(1024);
(*_configJson)["jsonkey"] = "Hello World"; // **** note the ()
if (_configJson->containsKey("jsonkey")) {
Serial.println((const char*) (*_configJson)["jsonkey"]); // **** note the ()
}
}
void loop() {}