StaticJsonDocument with a variable to set the size

Hello

is there any way to create a StaticJsonDocument using a variable as a size:

Example:

String myJson = "{\"hello\":\"world\"}"; //(the size can change)
StaticJsonDocument<myJson.length()> jsonDocument;

I get the following error:

exit status 1
call to non-constexpr function 'unsigned int String::length() const'

I'm using a <ArduinoJson.h> library (6.18.4)

thanks

I just looked at the documentation:

"In older versions, DynamicJsonDocument was able to grow if needed. Starting with version 6.7.0, DynamicJsonDocument has a fixed capacity, just like StaticJsonDocument. This change allows better performance, smaller code, and no heap fragmentation."

I think that means 'No, there is no way to set the size of a JsonDocument to a run-time calculated value.'