This commit is contained in:
Benoit Blanchon
2023-08-19 16:08:12 +02:00
parent 7bd2ea1072
commit 750d53f8c7
38 changed files with 207 additions and 206 deletions

View File

@ -17,7 +17,7 @@
// * CLK <-> pin 13
// * CS <-> pin 4
//
// https://arduinojson.org/v6/example/config/
// https://arduinojson.org/v7/example/config/
#include <ArduinoJson.h>
#include <SD.h>
@ -136,7 +136,7 @@ void loop() {
// ------------------
//
// File is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See: https://arduinojson.org/v7/how-to/improve-speed/
// See also
// --------

View File

@ -4,7 +4,7 @@
//
// This example shows how to use DeserializationOption::Filter
//
// https://arduinojson.org/v6/example/filter/
// https://arduinojson.org/v7/example/filter/
#include <ArduinoJson.h>

View File

@ -4,7 +4,7 @@
//
// This example shows how to generate a JSON document with ArduinoJson.
//
// https://arduinojson.org/v6/example/generator/
// https://arduinojson.org/v7/example/generator/
#include <ArduinoJson.h>
@ -21,12 +21,12 @@ void setup() {
doc["sensor"] = "gps";
doc["time"] = 1351824120;
// Add an array.
// Add an array
JsonArray data = doc["data"].to<JsonArray>();
data.add(48.756080);
data.add(2.302038);
// Generate the minified JSON and send it to the Serial port.
// Generate the minified JSON and send it to the Serial port
serializeJson(doc, Serial);
// The above line prints:
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
@ -34,7 +34,7 @@ void setup() {
// Start a new line
Serial.println();
// Generate the prettified JSON and send it to the Serial port.
// Generate the prettified JSON and send it to the Serial port
serializeJsonPretty(doc, Serial);
// The above line prints:
// {

View File

@ -16,7 +16,7 @@
// ]
// }
//
// https://arduinojson.org/v6/example/http-client/
// https://arduinojson.org/v7/example/http-client/
#include <ArduinoJson.h>
#include <Ethernet.h>
@ -108,7 +108,7 @@ void loop() {
// ------------------
//
// EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See: https://arduinojson.org/v7/how-to/improve-speed/
// See also
// --------

View File

@ -4,7 +4,7 @@
//
// This example shows how to deserialize a JSON document with ArduinoJson.
//
// https://arduinojson.org/v6/example/parser/
// https://arduinojson.org/v7/example/parser/
#include <ArduinoJson.h>
@ -24,14 +24,14 @@ void setup() {
// Deserialize the JSON document
DeserializationError error = deserializeJson(doc, json);
// Test if parsing succeeds.
// Test if parsing succeeds
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
// Fetch values.
// Fetch the values
//
// Most of the time, you can rely on the implicit casts.
// In other case, you can do doc["time"].as<long>();
@ -40,7 +40,7 @@ void setup() {
double latitude = doc["data"][0];
double longitude = doc["data"][1];
// Print values.
// Print the values
Serial.println(sensor);
Serial.println(time);
Serial.println(latitude, 6);

View File

@ -13,7 +13,7 @@
// "digital": [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0]
// }
//
// https://arduinojson.org/v6/example/http-server/
// https://arduinojson.org/v7/example/http-server/
#include <ArduinoJson.h>
#include <Ethernet.h>
@ -102,7 +102,7 @@ void loop() {
// ------------------
//
// EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See: https://arduinojson.org/v7/how-to/improve-speed/
// See also
// --------

View File

@ -17,7 +17,7 @@
// $ ncat -ulp 8888
// See https://nmap.org/ncat/
//
// https://arduinojson.org/v6/example/udp-beacon/
// https://arduinojson.org/v7/example/udp-beacon/
#include <ArduinoJson.h>
#include <Ethernet.h>
@ -90,7 +90,7 @@ void loop() {
// ------------------
//
// EthernetUDP is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See: https://arduinojson.org/v7/how-to/improve-speed/
// See also
// --------

View File

@ -5,7 +5,7 @@
// This example shows how to deserialize a MessagePack document with
// ArduinoJson.
//
// https://arduinojson.org/v6/example/msgpack-parser/
// https://arduinojson.org/v7/example/msgpack-parser/
#include <ArduinoJson.h>
@ -18,7 +18,7 @@ void setup() {
// Allocate the JSON document
JsonDocument doc;
// MessagePack input string.
// The MessagePack input string
uint8_t input[] = {131, 166, 115, 101, 110, 115, 111, 114, 163, 103, 112, 115,
164, 116, 105, 109, 101, 206, 80, 147, 50, 248, 164, 100,
97, 116, 97, 146, 203, 64, 72, 96, 199, 58, 188, 148,
@ -30,16 +30,17 @@ void setup() {
// "data": [48.75608, 2.302038]
// }
// Parse the input
DeserializationError error = deserializeMsgPack(doc, input);
// Test if parsing succeeded.
// Test if parsing succeeded
if (error) {
Serial.print("deserializeMsgPack() failed: ");
Serial.println(error.f_str());
return;
}
// Fetch values.
// Fetch the values
//
// Most of the time, you can rely on the implicit casts.
// In other case, you can do doc["time"].as<long>();
@ -48,7 +49,7 @@ void setup() {
double latitude = doc["data"][0];
double longitude = doc["data"][1];
// Print values.
// Print the values
Serial.println(sensor);
Serial.println(time);
Serial.println(latitude, 6);

View File

@ -9,7 +9,7 @@
// JsonDocument. Prefer plain old char*, as they are more efficient in term of
// code size, speed, and memory usage.
//
// https://arduinojson.org/v6/example/progmem/
// https://arduinojson.org/v7/example/progmem/
#include <ArduinoJson.h>

View File

@ -8,7 +8,7 @@
// JsonDocument. Prefer plain old char[], as they are more efficient in term of
// code size, speed, and memory usage.
//
// https://arduinojson.org/v6/example/string/
// https://arduinojson.org/v7/example/string/
#include <ArduinoJson.h>