A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://arduinojson.org/v6/api/jsondocument/to/ below:

JsonDocument::to<T>() | ArduinoJson 6

Description

Clears the JsonDocument and converts it to the specified type.

Signature
JsonArray   to<JsonArray>();
JsonObject  to<JsonObject>();
JsonVariant to<JsonVariant>();
Example
// allocate the JsonDocument
StaticJsonDocument<200> doc;

// convert it to a JsonObject
JsonObject root = doc.to<JsonObject>();

// set values
root["hello"] = "world";
Invalidates references

Because this function releases memory owned by the JsonDocument, it invalidates all references acquired before.

Example:

DynamicJsonDocument doc(1024);

JsonObject root1 = doc.to<JsonObject>();

JsonObject root2 = doc.to<JsonObject>();

// Don't use root1 here, because it's dangling!
See also
  1. Home
  2. Version 6
  3. API
  4. JsonDocument
  5. to<T>()

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4