scalar_range json serialization

This commit is contained in:
2021-03-19 16:28:40 +01:00
parent 84bd115ebd
commit 0a1895d0be
4 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#pragma once
#include <nlohmann/json.hpp>
#include "../scalar_range2.hpp"
namespace MM {
template<typename T>
void to_json(nlohmann::json& j, const ScalarRange2<T>& r) {
j = nlohmann::json{
{"min", r.min()},
{"max", r.max()}
};
}
template<typename T>
void from_json(const nlohmann::json& j, ScalarRange2<T>& r) {
j.at("min").get_to(r.min());
j.at("max").get_to(r.max());
r.sanitize();
}
} // MM