mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 21:34:08 +01:00
Add toCharArray method
This commit is contained in:
@@ -19,6 +19,7 @@ struct JsonStruct
|
|||||||
{
|
{
|
||||||
return json.success();
|
return json.success();
|
||||||
};
|
};
|
||||||
|
|
||||||
String toJsonString()
|
String toJsonString()
|
||||||
{
|
{
|
||||||
DynamicJsonBuffer jsonBuffer(JSON_ARRAY_SIZE(300));
|
DynamicJsonBuffer jsonBuffer(JSON_ARRAY_SIZE(300));
|
||||||
@@ -28,6 +29,16 @@ struct JsonStruct
|
|||||||
root.printTo(jsonString);
|
root.printTo(jsonString);
|
||||||
return jsonString;
|
return jsonString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* toCharArray()
|
||||||
|
{
|
||||||
|
DynamicJsonBuffer jsonBuffer(JSON_ARRAY_SIZE(300));
|
||||||
|
JsonObject &root = jsonBuffer.createObject();
|
||||||
|
mapJsonObject(root);
|
||||||
|
char jsonChar[jsonBuffer.size()];
|
||||||
|
root.printTo((char*)jsonChar, root.measureLength() + 1);
|
||||||
|
return jsonChar;
|
||||||
|
}
|
||||||
|
|
||||||
String getAttrFromJson(JsonObject &json, const char *attr, String defautValue = "")
|
String getAttrFromJson(JsonObject &json, const char *attr, String defautValue = "")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user