forked from bblanchon/ArduinoJson
Merge DynamicJsonDocument
with JsonDocument
This commit is contained in:
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
//
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
//
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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.
|
||||
//
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user