disk_backend_file new serialization
This commit is contained in:
parent
eda3dd9866
commit
982f232e8f
2 changed files with 10 additions and 10 deletions
|
@ -23,23 +23,24 @@ disk_backend_file::~disk_backend_file()
|
|||
|
||||
JsonDocument disk_backend_file::serialize() const
|
||||
{
|
||||
json_t *j = json_object();
|
||||
JsonDocument j;
|
||||
|
||||
json_object_set(j, "disk-backend-type", json_string("file"));
|
||||
j["disk-backend-type"] = "file";
|
||||
|
||||
json_object_set(j, "overlay", serialize_overlay());
|
||||
j["overlay"] = serialize_overlay();
|
||||
|
||||
// TODO store checksum of backend
|
||||
json_object_set(j, "filename", json_string(filename.c_str()));
|
||||
|
||||
j["filename"] = filename;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
disk_backend_file *disk_backend_file::deserialize(const json_t *const j)
|
||||
disk_backend_file *disk_backend_file::deserialize(const JsonDocument j)
|
||||
{
|
||||
// TODO verify checksum of backend
|
||||
// TODO overlay
|
||||
return new disk_backend_file(json_string_value(json_object_get(j, "filename")));
|
||||
return new disk_backend_file(j["filename"]);
|
||||
}
|
||||
|
||||
bool disk_backend_file::begin(const bool snapshots)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// (C) 2018-2024 by Folkert van Heusden
|
||||
// Released under MIT license
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <string>
|
||||
|
||||
#include "disk_backend.h"
|
||||
|
@ -17,10 +18,8 @@ public:
|
|||
disk_backend_file(const std::string & filename);
|
||||
virtual ~disk_backend_file();
|
||||
|
||||
#if IS_POSIX
|
||||
json_t *serialize() const override;
|
||||
static disk_backend_file *deserialize(const json_t *const j);
|
||||
#endif
|
||||
JsonDocument serialize() const override;
|
||||
static disk_backend_file *deserialize(const JsonDocument j);
|
||||
|
||||
std::string get_identifier() const override { return filename; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue