If you try to reassign a JsonArray or a JsonObject, you’ll have the following error:

error: use of deleted function 'ArduinoJson::JsonArray& ArduinoJson::JsonArray::operator=(const ArduinoJson::JsonArray&)'
error: use of deleted function 'ArduinoJson::JsonObject& ArduinoJson::JsonObject::operator=(const ArduinoJson::JsonObject&)'

Indeed, JsonArray and JsonObject have their assignment operators private, so you cannot reassign them. Moreover, it’s impossible to reassign a C++ reference.

One solution is to use a pointer instead.

JsonObject* myObject = &root["myObject"].as<JsonObject>();

You can also use a JsonVariant which will act as a wrapper around the pointer.

JsonVariant myObject = root["myObject"];
 X online