mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-02 20:24:42 +02:00
Created Examples (markdown)
26
Examples.md
Normal file
26
Examples.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
## Example 1: complex nested object
|
||||||
|
|
||||||
|
From [issue #85](https://github.com/bblanchon/ArduinoJson/issues/85):
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"error": {
|
||||||
|
"address": "",
|
||||||
|
"description": "link button not pressed",
|
||||||
|
"type": "101"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Can be generated by the following code:
|
||||||
|
|
||||||
|
DynamicJsonBuffer jsonBuffer;
|
||||||
|
JsonArray& root = jsonBuffer.createArray();
|
||||||
|
JsonObject& error = root.createNestedObject().createNestedObject("error");
|
||||||
|
error["address"] = "";
|
||||||
|
error["description"] = "link button not pressed";
|
||||||
|
error["type"] = "101";
|
||||||
|
root.prettyPrintTo(Serial);
|
||||||
|
|
||||||
|
Don't forget to replace the `DynamicJsonBuffer` by a `StaticJsonBuffer` if you need to run on an embedded platform like an Arduino.
|
||||||
|
|
Reference in New Issue
Block a user