Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
JsonService.h
Go to the documentation of this file.
1
16#pragma once
17
18#include <string>
19#include <vector>
20#include "StorageManager.h"
21#include "nlohmann/json.hpp"
22
28{
29public:
35
41 bool load(const std::string &path);
42
48 bool save(const std::string &path) const;
49
53 nlohmann::json &data();
54
58 const nlohmann::json &data() const;
59
63 nlohmann::json &root();
64
68 const nlohmann::json &root() const;
69
73 nlohmann::json &operator*();
74
78 const nlohmann::json &operator*() const;
79
80 bool hasValidData() const;
81
82 private:
84 nlohmann::json data_;
85 };
86
96 nlohmann::json mergeDefaults(const nlohmann::json &target, const nlohmann::json &defaults);
nlohmann::json mergeDefaults(const nlohmann::json &target, const nlohmann::json &defaults)
Merge a default JSON structure into a target, preserving existing keys.
Abstract interface for file and directory storage backends.
Manages loading and saving of a single JSON document using StorageManager.
Definition JsonService.h:28
nlohmann::json & operator*()
Operator alias for data().
nlohmann::json & data()
Access the internal JSON object.
bool hasValidData() const
nlohmann::json & root()
Alias for data().
nlohmann::json data_
Definition JsonService.h:84
bool save(const std::string &path) const
Save the current JSON data to storage.
StorageManager * storage
Definition JsonService.h:83
bool load(const std::string &path)
Load a JSON file from storage.
Abstract base class for storage access and file operations.