123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include <ArduinoJson.h>
- void setup() {
-
- Serial.begin(9600);
- while (!Serial) continue;
-
-
-
-
-
- StaticJsonDocument<200> doc;
-
-
-
-
-
-
-
-
-
-
-
-
- char json[] =
- "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
-
- DeserializationError error = deserializeJson(doc, json);
-
- if (error) {
- Serial.print(F("deserializeJson() failed: "));
- Serial.println(error.f_str());
- return;
- }
-
-
-
-
- const char* sensor = doc["sensor"];
- long time = doc["time"];
- double latitude = doc["data"][0];
- double longitude = doc["data"][1];
-
- Serial.println(sensor);
- Serial.println(time);
- Serial.println(latitude, 6);
- Serial.println(longitude, 6);
- }
- void loop() {
-
- }
|