mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 04:22:18 +02:00
Updated example
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* malloc-free JSON parser for Arduino
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "JsonParser/JsonArray.cpp"
|
#include "JsonParser/JsonArray.cpp"
|
||||||
#include "JsonParser/JsonHashTable.cpp"
|
#include "JsonParser/JsonHashTable.cpp"
|
||||||
#include "JsonParser/JsonObjectBase.cpp"
|
|
||||||
#include "JsonParser/JsonParserBase.cpp"
|
#include "JsonParser/JsonParserBase.cpp"
|
||||||
#include "JsonParser/JsonValue.cpp"
|
#include "JsonParser/JsonValue.cpp"
|
||||||
#include "JsonParser/jsmn.cpp"
|
#include "JsonParser/jsmn.cpp"
|
@ -15,27 +15,23 @@ void setup()
|
|||||||
|
|
||||||
JsonParser<16> parser;
|
JsonParser<16> parser;
|
||||||
|
|
||||||
JsonHashTable root = parser.parseHashTable(json);
|
JsonValue root = parser.parse(json);
|
||||||
|
|
||||||
if (!root.success())
|
if (!root.success())
|
||||||
{
|
{
|
||||||
Serial.println("JsonParser.parseHashTable() failed");
|
Serial.println("JsonParser.parse() failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* sensor = root["sensor"];
|
char* sensor = root["sensor"];
|
||||||
Serial.println(sensor);
|
|
||||||
|
|
||||||
long time = root["time"];
|
long time = root["time"];
|
||||||
|
double latitude = root["data"][0];
|
||||||
|
double longitude = root["data"][1];
|
||||||
|
|
||||||
|
Serial.println(sensor);
|
||||||
Serial.println(time);
|
Serial.println(time);
|
||||||
|
Serial.println(latitude, 6);
|
||||||
JsonArray coords = root["data"];
|
Serial.println(longitude, 6);
|
||||||
|
|
||||||
for (int i = 0; i < coords.size(); i++)
|
|
||||||
{
|
|
||||||
double value = coords[i];
|
|
||||||
Serial.println(value, 6);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
Reference in New Issue
Block a user