1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #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.c_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() {
-
- }
|