Just so you know, I was able to get to that point with this documentation from ArduinoJson.
The important part to note here is:
JsonDocument::to() clears the document and converts it to the specified type. Don’t confuse this function with JsonDocument::as() that returns a reference only if the requested type matches the one in the document.
Happy that we were able to get you sorted out!
Enjoy,
Heath