mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-17 19:41:16 +02:00
Updated Quick Start (markdown)
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#### Decoding / Parsing
|
#### Decoding / Parsing
|
||||||
|
|
||||||
|
```c++
|
||||||
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||||
|
|
||||||
StaticJsonBuffer<200> jsonBuffer;
|
StaticJsonBuffer<200> jsonBuffer;
|
||||||
@@ -12,11 +13,13 @@
|
|||||||
long time = root["time"];
|
long time = root["time"];
|
||||||
double latitude = root["data"][0];
|
double latitude = root["data"][0];
|
||||||
double longitude = root["data"][1];
|
double longitude = root["data"][1];
|
||||||
|
```
|
||||||
|
|
||||||
[See complete guide](../Decoding-JSON)
|
[See complete guide](../Decoding-JSON)
|
||||||
|
|
||||||
#### Encoding / Generating
|
#### Encoding / Generating
|
||||||
|
|
||||||
|
```c++
|
||||||
StaticJsonBuffer<200> jsonBuffer;
|
StaticJsonBuffer<200> jsonBuffer;
|
||||||
|
|
||||||
JsonObject& root = jsonBuffer.createObject();
|
JsonObject& root = jsonBuffer.createObject();
|
||||||
@@ -30,5 +33,6 @@
|
|||||||
root.printTo(Serial);
|
root.printTo(Serial);
|
||||||
// This prints:
|
// This prints:
|
||||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||||
|
```
|
||||||
|
|
||||||
[See complete guide](../Encoding-JSON)
|
[See complete guide](../Encoding-JSON)
|
Reference in New Issue
Block a user