fpmas 1.6
json.h
Go to the documentation of this file.
1#ifndef FPMAS_JSON_H
2#define FPMAS_JSON_H
3
8#include "nlohmann/json.hpp"
9#include "../api/utils/ptr_wrapper.h"
10
11namespace fpmas { namespace io { namespace json {
12 using api::utils::PtrWrapper;
13
14 template<typename T, typename> struct light_serializer;
15
28 typedef nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, light_serializer> light_json;
29
93 template<typename T, typename Enable = void>
107 static void to_json(light_json& j, const T& data) {
108 nlohmann::adl_serializer<T>::to_json(j, data);
109 }
110
123 static void from_json(const light_json& j, T& data) {
124 nlohmann::adl_serializer<T>::from_json(j, data);
125 }
126 };
127
135 template<typename T>
136 struct light_serializer<T, typename std::enable_if<!std::is_default_constructible<T>::value>::type> {
149 static void to_json(light_json& j, const T& data) {
150 nlohmann::adl_serializer<T>::to_json(j, data);
151 }
152
165 static T from_json(const light_json& j) {
166 return nlohmann::adl_serializer<T>::from_json(j);
167 }
168 };
169}}}
170#endif
nlohmann::basic_json< std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator, light_serializer > light_json
Definition: json.h:14
Definition: fpmas.cpp:3
static void from_json(const light_json &j, T &data)
Definition: json.h:123
static void to_json(light_json &j, const T &data)
Definition: json.h:107