How To Create Nested Object In Nested Array? · Issue #380 - GitHub
Maybe your like
Skip to content You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} bblanchon / ArduinoJson Public 
tarzan115opened on Nov 4, 2016
-
Uh oh!
There was an error while loading. Please reload this page.
- Notifications You must be signed in to change notification settings
- Fork 1.2k
- Star 7.1k
- Code
- Issues 19
- Pull requests 0
- Actions
- Security 0
- Insights
Description
Hi, Thank you for your Library. I got a problem when create a JSON
here is what I want:
{ "METHOD": "GET", "ID": "123", "BTN": [ { "ID":"1", "STT": "0" }, { "ID":"2", "STT": "1" }, { "ID":"3", "STT": "0" } ], "IP": "192.168.1.7", "VER": "Version", "PW": "Power", "TEMP": "Temperature" }and here is my code:
void sendJson(const ClientDATA& data, String json = "") { StaticJsonBuffer<CLIENT_DATA_JSON_SIZE> jsonBuffer; JsonObject& root = jsonBuffer.createObject(); JsonArray& Button = root.createNestedArray("BTN"); root["METHOD"] = data.Method; root["ID"] = data.ID; root["IP"] = data.IP; root["VER"] = data.Version; root["PW"] = data.Power; root["TEMP"] = data.Temperature; JsonObject& Button1 = Button.createNestedObject(); Button1["ID"] = data.ButtonID[0]; Button1["STT"] = data.Status[0]; JsonObject& Button2 = Button.createNestedObject(); Button2["ID"] = data.ButtonID[1]; Button2["STT"] = data.Status[1]; JsonObject& Button3 = Button.createNestedObject(); Button3["ID"] = data.ButtonID[2]; Button3["STT"] = data.Status[2]; // for(int i=0; i<3; i++){ // JsonObject& ButtonID = Button.createNestedObject(); // ButtonID["ID"] = data.ButtonID[i]; // ButtonID["STT"] = data.Status[i]; // } // // Button.add(ButtonID); // ButtonID["ID"] = data.ButtonID[1]; // ButtonID["STT"] = data.Status[1]; // // Button.add(ButtonID); // ButtonID["ID"] = data.ButtonID[2]; // ButtonID["STT"] = data.Status[2]; // Button.add(ButtonID); // root.printTo(json); root.prettyPrintTo(Serial); }I also try loop:
for(int i=0; i<3; i++){ JsonObject& ButtonID = Button.createNestedObject(); ButtonID["ID"] = data.ButtonID[i]; ButtonID["STT"] = data.Status[i]; }But I always got 2 elements of "BTN" like:
{ "METHOD": "GET", "ID": "123", "BTN": [ { "ID":"1", "STT": "0" }, { "ID":"2", "STT": "1" } ], "IP": "192.168.1.7", "VER": "Version", "PW": "Power", "TEMP": "Temperature" }please explain how to create that JSON. thank you so much.
Metadata
Metadata
Assignees
No one assignedLabels
ArduinoJson 5Projects
No projectsMilestone
No milestoneRelationships
None yetDevelopment
No branches or pull requestsIssue actions
You can’t perform that action at this time.Tag » Arduino Json 6 Nested Array
-
JsonDocument::createNestedArray() | ArduinoJson 6
-
JsonArray | ArduinoJson 6
-
ArduinoJson Nested Array - Programming Questions - Arduino Forum
-
How To Create Nested Json Using ArduinoJson On ESP8266
-
Nested Array Can Not Contain Other Arrays? · Issue #51 - GitHub
-
ESP8266: Parsing JSON Arrays - Techtutorialsx
-
C++ ArduinoJson::JsonArray::createNestedObject() - CPPSECRETS
-
[தமிழ்] Create JSON String With Nested JSON & JSON Array
-
Mastering ArduinoJson 6 - PDFCOFFEE.COM
-
Arduino -Sending And Receiving JSON Data Over MQTT
-
Fun With ESP32 + Arduino (15) ArduinoJSON Library (V6 Version)
-
Decoding And Encoding JSON Arduino | Random Nerd Tutorials
-
ArduinoJSON: Serialize And Deserialize - Tutorialspoint
-
How To Use A Multidimensional Json Array In Android Studio ...