GuillaumeDua / CppShelf

Collection of powerfuls - C++ Single-Header Libraries Files
https://guillaumedua.github.io/CppShelf/
MIT License
9 stars 1 forks source link

[ag] opt-in feature: nlohmann/json adl_serializer #239

Open GuillaumeDua opened 2 months ago

GuillaumeDua commented 2 months ago

nlohmann/json adl_serializer

for-each fields

template <typename T>
concept json_serializable = mp::concepts::complete<T> and
and requires (T value){
    { nlohmann::json(value) } -> std::same_as<nlohmann::json>;
};
template <typename T>
concept deserializable = mp::concepts::complete<T>
and requires(const nlohmann::json & j) {
    { j.get<T>() } -> std::same_as<T>;
};