blob: ea4508708bd1e4fb6fa20c65cdd4632432a603c3 (
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
|
#pragma once
#include "compat/exception.hpp"
#include <Corrade/Containers/Array.h>
#include <nlohmann/json.hpp>
namespace nlohmann {
template<typename T, typename D>
struct adl_serializer<Corrade::Containers::Array<T, D>>
{
static void to_json(json& j, const Corrade::Containers::Array<T, D>& array)
{
j.clear();
for (const T& x : array)
j.push_back(x);
}
static void from_json(const json& j, Corrade::Containers::Array<T>& array)
{
fm_soft_assert(j.is_array());
auto size = (uint32_t)j.size();
array = Corrade::Containers::Array<T>{size};
for (uint32_t i = 0; i < size; i++)
array[i] = j[i];
}
};
} // namespace nlohmann
|