ArduinoJSON v6 - Passing buffer as function parameter
The StaticJsonDocument is a template class. The template value in &lt;> is here only the size of the internal buffer, but every size used generates a different class. (memory usage!)

To have the parameter of the function take an StaticJsonDocument version instance, it must be the same version or a common base class. In this case the base class is JsonDocument.

If you don't use the reference symbol &amp; the parameter is copied. In this case StaticJsonDocument&lt;200&gt; _doc or JsonDocument _doc would create a copy and that copy would be modified in the function. The object used as parameter value would be unchanged - empty.

So use

void test2(const JsonDocument&amp; _doc) {
  Serial.println("HI");
  serializeJson(_doc, Serial);
}