ifm3d
json.hpp
1 // -*- c++ -*-
2 /*
3  * Copyright 2023-present ifm electronic, gmbh
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef IFM3D_DEVICE_JSON_HPP
8 #define IFM3D_DEVICE_JSON_HPP
9 
10 #ifdef DOXYGEN
11 
12 namespace ifm3d
13 {
128  class json
129  {
130  };
131 }
132 
133 #else
134 
135 # ifndef IFM3D_JSON_USE_GLOBAL_UDLS
136 # define IFM3D_JSON_USE_GLOBAL_UDLS 0
137 # endif
138 
139 # include <ifm3d/common/json_impl.hpp>
140 
141 # ifdef IFM3D_JSON_NLOHMANN_COMPAT
142 # ifndef NLOHMANN_JSON_VERSION_MAJOR
143 # error Enabled ifm3d::json nlohmann::json compatiblity but nlohmann::json ist not available, make sure to include "nlohmann/json.hpp" before including "ifm3d/device/json.hpp"!
144 # endif
145 
146 namespace nlohmann
147 {
148  template <>
149  struct adl_serializer<ifm3d::json>
150  {
151  static ifm3d::json
152  from_json(const nlohmann::json& nl)
153  {
154  return ifm3d::json::parse(nl.dump(0));
155  }
156 
157  static void
158  to_json(nlohmann::json& nl, ifm3d::json ifm)
159  {
160  nl = nlohmann::json::parse(ifm.dump(0));
161  }
162  };
163 }
164 
165 # endif // IFM3D_JSON_NLOHMANN_COMPAT
166 
167 #endif
168 
169 #endif // IFM3D_DEVICE_JSON_HPP
ifm3d::json
Definition: json.hpp:128