Merge DynamicJsonDocument with JsonDocument

This commit is contained in:
Benoit Blanchon
2023-03-20 10:49:01 +01:00
parent db9258bcd7
commit 540901e219
164 changed files with 550 additions and 666 deletions

View File

@ -45,7 +45,7 @@ void loadConfiguration(const char* filename, Config& config) {
// Allocate a temporary JsonDocument
// Don't forget to change the capacity to match your requirements.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(512);
JsonDocument doc(512);
// Deserialize the JSON document
DeserializationError error = deserializeJson(doc, file);
@ -77,7 +77,7 @@ void saveConfiguration(const char* filename, const Config& config) {
// Allocate a temporary JsonDocument
// Don't forget to change the capacity to match your requirements.
// Use https://arduinojson.org/assistant to compute the capacity.
DynamicJsonDocument doc(256);
JsonDocument doc(256);
// Set the values in the document
doc["hostname"] = config.hostname;

View File

@ -34,12 +34,12 @@ void setup() {
"1000000,\"timezone\":0,\"sunrise\":1581492085,\"sunset\":1581527294}}");
// The filter: it contains "true" for each value we want to keep
DynamicJsonDocument filter(200);
JsonDocument filter(200);
filter["list"][0]["dt"] = true;
filter["list"][0]["main"]["temp"] = true;
// Deserialize the document
DynamicJsonDocument doc(400);
JsonDocument doc(400);
deserializeJson(doc, input_json, DeserializationOption::Filter(filter));
// Print the result

View File

@ -19,7 +19,7 @@ void setup() {
// Inside the parentheses, 200 is the RAM allocated to this document.
// Don't forget to change this value to match your requirement.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);
// Add values in the document
//

View File

@ -79,7 +79,7 @@ void setup() {
// Allocate the JSON document
// Use https://arduinojson.org/v6/assistant to compute the capacity.
const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
DynamicJsonDocument doc(capacity);
JsonDocument doc(capacity);
// Parse JSON object
DeserializationError error = deserializeJson(doc, client);

View File

@ -19,7 +19,7 @@ void setup() {
// Inside the parentheses, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);
// JSON input string.
//

View File

@ -58,7 +58,7 @@ void loop() {
// Allocate a temporary JsonDocument
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(500);
JsonDocument doc(500);
// Create the "analog" array
JsonArray analogValues = doc.createNestedArray("analog");

View File

@ -48,7 +48,7 @@ void setup() {
void loop() {
// Allocate a temporary JsonDocument
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(500);
JsonDocument doc(500);
// Create the "analog" array
JsonArray analogValues = doc.createNestedArray("analog");

View File

@ -20,7 +20,7 @@ void setup() {
// Inside the parentheses, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
DynamicJsonDocument doc(200);
JsonDocument doc(200);
// MessagePack input string.
//

View File

@ -14,7 +14,7 @@
#include <ArduinoJson.h>
void setup() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
// You can use a Flash String as your JSON input.
// WARNING: the strings in the input will be duplicated in the JsonDocument.

View File

@ -13,7 +13,7 @@
#include <ArduinoJson.h>
void setup() {
DynamicJsonDocument doc(1024);
JsonDocument doc(1024);
// You can use a String as your JSON input.
// WARNING: the string in the input will be duplicated in the JsonDocument.