summaryrefslogtreecommitdiffhomepage
path: root/serialize/json-helper.hpp
blob: 90ce2e9a8a9a6c28303b181d31292d4766f1dac8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once
#include <nlohmann/json.hpp>
#include <Corrade/Containers/StringView.h>

namespace floormat {

struct json_helper final {
    using json = nlohmann::json;

    template<typename T> static T from_json(StringView pathname);
    template<typename T> static void to_json(const T& self, StringView pathname, int indent = 1);
    static json from_json_(StringView pathname);
    static void to_json_(const json& j, StringView pathname, int indent);
};

template<typename T> T json_helper::from_json(StringView pathname) { return from_json_(pathname); }
template<typename T> void json_helper::to_json(const T& self, StringView pathname, int indent) { to_json_(json(self), pathname, indent); }

} // namespace floormat