Description

JsonVariant::to<T>() clears the content of the variant and changes its type to T.

Signatures

JsonArray  to<JsonArray>() const;
JsonObject to<JsonObject>() const;

Return value

A reference to the new value of the variant.

Example

void fillConfig(JsonVariant variant) {
  JsonObject config = variant.to<JsonObject>();
  config["host"] = "127.0.0.1";
  config["port"] = 80;
}

See also