Skip to content

Commit 23cbf4a

Browse files
added a sample file to convert String to JSON Array
1 parent efbfe56 commit 23cbf4a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

JSON_Data/JSON_Data.ino

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <ArduinoJson.h>
2+
3+
void setup() {
4+
DynamicJsonBuffer jsonBuffer;
5+
6+
Serial.begin(9600);
7+
String response = "{'status':206,'message':'Valid.','data':[]}";
8+
JsonObject& root = jsonBuffer.parseObject(response);
9+
10+
int response_status = root["status"];
11+
String response_message = root["message"];
12+
String data = root["data"];
13+
14+
Serial.print("status : ");
15+
Serial.println(response_status);
16+
Serial.print("message : ");
17+
Serial.println(response_message);
18+
Serial.print("data : ");
19+
Serial.println(data);
20+
}
21+
22+
void loop() {
23+
// put your main code here, to run repeatedly:
24+
25+
}

0 commit comments

Comments
 (0)