mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-20 03:36:37 +02:00
scalar_range json serialization
This commit is contained in:
26
framework/std_utils/src/mm/serialize/json_scalar_range2.hpp
Normal file
26
framework/std_utils/src/mm/serialize/json_scalar_range2.hpp
Normal 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
|
||||
|
Reference in New Issue
Block a user