mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 08:48:27 +01:00
Return JsonArray and JsonObject by value (closes #309)
This commit is contained in:
@@ -33,28 +33,26 @@ class StaticJsonDocument {
|
||||
return _root.as<T>();
|
||||
}
|
||||
|
||||
// JsonObject& to<JsonObject>()
|
||||
// JsonObject to<JsonObject>()
|
||||
template <typename T>
|
||||
typename Internals::enable_if<Internals::is_same<T, JsonObject>::value,
|
||||
JsonObject&>::type
|
||||
JsonObject>::type
|
||||
to() {
|
||||
clear();
|
||||
JsonObject* object = new (&_buffer) JsonObject(&_buffer);
|
||||
if (!object) return JsonObject::invalid();
|
||||
JsonObject object(&_buffer);
|
||||
_root = object;
|
||||
return *object;
|
||||
return object;
|
||||
}
|
||||
|
||||
// JsonArray& to<JsonArray>()
|
||||
// JsonArray to<JsonArray>()
|
||||
template <typename T>
|
||||
typename Internals::enable_if<Internals::is_same<T, JsonArray>::value,
|
||||
JsonArray&>::type
|
||||
JsonArray>::type
|
||||
to() {
|
||||
clear();
|
||||
JsonArray* array = new (&_buffer) JsonArray(&_buffer);
|
||||
if (!array) return JsonArray::invalid();
|
||||
JsonArray array(&_buffer);
|
||||
_root = array;
|
||||
return *array;
|
||||
return array;
|
||||
}
|
||||
|
||||
// JsonVariant to<JsonVariant>()
|
||||
|
||||
Reference in New Issue
Block a user