Mike的分享空间
Arduino处理json
date: 2018.03.25; modification:2018.03.25
目录:
1 程序
#include
DynamicJsonBuffer jsonBuffer;
Serial.begin(115200);
Serial.println("\r\n\n\nStart");
// 序列化(json对象转字符串)
JsonObject& testRoot = jsonBuffer.createObject();
testRoot["key1"] = "value1";
testRoot["key2"] = 12345;
JsonArray& data = testRoot.createNestedArray("data");
data.add(48.756080);
data.add(54321);
String strJson2;
testRoot.printTo(strJson2);
Serial.println(String() + F("Json string:") + strJson2);
Serial.println("\n\n");
// json字符串转对象
String input = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
JsonObject& root