mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-08-18 03:51:21 +02:00
Updated FAQ (markdown)
6
FAQ.md
6
FAQ.md
@@ -111,9 +111,11 @@ struct SensorData {
|
|||||||
float value;
|
float value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SENSORDATA_JSON_SIZE (JSON_OBJECT_SIZE(3))
|
||||||
|
|
||||||
bool deserialize(SensorData& data, const char* json)
|
bool deserialize(SensorData& data, const char* json)
|
||||||
{
|
{
|
||||||
StaticJsonBuffer<200> jsonBuffer;
|
StaticJsonBuffer<SENSORDATA_JSON_SIZE> jsonBuffer;
|
||||||
JsonObject& root = jsonBuffer.parseObject(json)
|
JsonObject& root = jsonBuffer.parseObject(json)
|
||||||
data.name = json["name"];
|
data.name = json["name"];
|
||||||
data.time = json["time"];
|
data.time = json["time"];
|
||||||
@@ -123,7 +125,7 @@ bool deserialize(SensorData& data, const char* json)
|
|||||||
|
|
||||||
void serialize(const SensorData& data, char* json, size_t maxSize)
|
void serialize(const SensorData& data, char* json, size_t maxSize)
|
||||||
{
|
{
|
||||||
StaticJsonBuffer<200> jsonBuffer;
|
StaticJsonBuffer<SENSORDATA_JSON_SIZE> jsonBuffer;
|
||||||
JsonObject& root = jsonBuffer.createObject()
|
JsonObject& root = jsonBuffer.createObject()
|
||||||
root["name"] = data.name;
|
root["name"] = data.name;
|
||||||
root["time"] = data.time;
|
root["time"] = data.time;
|
||||||
|
Reference in New Issue
Block a user