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 // NOLINTBEGIN
11 
12 #ifdef DOXYGEN
13 
14 namespace ifm3d
15 {
130  class json
131  {
132  };
133 }
134 
135 #else
136 
137 # ifndef IFM3D_JSON_USE_GLOBAL_UDLS
138 # define IFM3D_JSON_USE_GLOBAL_UDLS 0
139 # endif
140 
141 # include <ifm3d/common/json_impl.hpp>
142 
143 # ifdef IFM3D_JSON_NLOHMANN_COMPAT
144 # ifndef NLOHMANN_JSON_VERSION_MAJOR
145 # 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"!
146 # endif
147 
148 namespace nlohmann
149 {
150  template <>
151  struct adl_serializer<ifm3d::json>
152  {
153  static ifm3d::json
154  from_json(const nlohmann::json& nl)
155  {
156  return ifm3d::json::parse(nl.dump(0));
157  }
158 
159  static void
160  to_json(nlohmann::json& nl, ifm3d::json ifm)
161  {
162  nl = nlohmann::json::parse(ifm.dump(0));
163  }
164  };
165 }
166 
167 # endif // IFM3D_JSON_NLOHMANN_COMPAT
168 
169 #endif
170 
171 // NOLINTEND
172 
173 #endif // IFM3D_DEVICE_JSON_HPP
ifm3d::json
Definition: json.hpp:130