blob: 7b772d4cbb8561785bbf8f1ee8ab79b692e5063b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "corrade-string.hpp"
#include <nlohmann/json.hpp>
#include <string_view>
using namespace floormat;
namespace nlohmann {
void adl_serializer<String>::to_json(json& j, const String& val)
{
std::string_view s{val.data(), val.size()};
using nlohmann::to_json;
to_json(j, s);
}
void adl_serializer<String>::from_json(const json& j, String& val)
{
using nlohmann::from_json;
std::string_view s;
from_json(j, s);
val = String{s.data(), s.size()};
}
void adl_serializer<StringView>::to_json(json& j, StringView val)
{
std::string_view s{val.data(), val.size()};
using nlohmann::to_json;
to_json(j, s);
}
void adl_serializer<StringView>::from_json(const json& j, StringView& val)
{
using nlohmann::from_json;
std::string_view s;
from_json(j, s);
val = StringView{s.data(), s.size()};
}
} // namespace nlohmann
|