Return JsonArray and JsonObject by value (closes #309)

This commit is contained in:
Benoit Blanchon
2018-07-02 09:35:21 +02:00
parent 4fe2b1100e
commit b105e6f7c4
93 changed files with 983 additions and 1091 deletions

View File

@ -56,10 +56,10 @@ void loop() {
StaticJsonDocument<500> doc;
// Make our document represent an object
JsonObject& root = doc.to<JsonObject>();
JsonObject root = doc.to<JsonObject>();
// Create the "analog" array
JsonArray& analogValues = root.createNestedArray("analog");
JsonArray analogValues = root.createNestedArray("analog");
for (int pin = 0; pin < 6; pin++) {
// Read the analog input
int value = analogRead(pin);
@ -69,7 +69,7 @@ void loop() {
}
// Create the "digital" array
JsonArray& digitalValues = root.createNestedArray("digital");
JsonArray digitalValues = root.createNestedArray("digital");
for (int pin = 0; pin < 14; pin++) {
// Read the digital input
int value = digitalRead(pin);
@ -95,15 +95,4 @@ void loop() {
client.stop();
}
// See also
// --------
//
// The website arduinojson.org contains the documentation for all the functions
// used above. It also includes an FAQ that will help you solve any
// serialization problem.
// Please check it out at: https://arduinojson.org/
//
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
// It begins with a simple example, then adds more features like serializing
// directly to a file or an HTTP client.
// Please check it out at: https://arduinojson.org/book/
// Visit https://arduinojson.org/v6/example/http-server/ for more.