3#include <unordered_map>
4#include <nlohmann/json.hpp>
9using json = nlohmann::json;
16template <
typename Key,
typename Type>
17void to_json (
json& j,
const std::unordered_map <Key, Type>& table)
21 for (
const auto& element : table) {
22 j [element.first] = element.second;
26template <
typename Key,
typename Type>
31 for (
auto elem = j.begin (); elem != j.end (); elem++) {
32 const Key key = elem.key ();
33 const Type value = elem.value ();
34 table.insert ({key, value});
42template <
typename Object,
typename ObjectId>
45 for (
const auto id : pool.
ids ()) {
46 j [id] = pool.
get (
id);
50template <
typename Object,
typename ObjectId>
53 for (
auto elem = j.begin (); elem != j.end (); elem++) {
54 const ObjectId
id = elem.key ();
55 const Object value = elem.value ();
nlohmann::json json
Definition LoadJson.h:8
: implement a generic pool of objects that are stored continuously in memory without fragmentation,...
Definition ObjectPool.h:16
std::vector< ObjectId > ids() const
Get list of all identifiers used to store object.
Object & get(const ObjectId &object)
Get oject in pool.
Object & add(Object &&object, const ObjectId &id)
Add object in pool.
Definition Interpolation.h:16
void from_json(const json &j, std::unordered_map< Key, Type > &table)
Definition SerializeCore.h:27
void to_json(json &j, const std::unordered_map< Key, Type > &table)
Definition SerializeCore.h:17