ifm3d
|
#include <ifm3d/common/json.hpp>
ifm3d provides a copy of nlohmann::json, please see it's documentation for detailed usage: https://json.nlohmann.me/
Working with both nlohmann::json and ifm3d::json together doesn't require any specific setup, however the types are not automatically convertible, so to get a nlohmann::json instance from a ifm3d::json instance one has to convert the json to a string and then parse it again.
To ease this conversion ifm3d provides a custom converter which can be used by defining IFM3D_JSON_NLOHMANN_COMPAT
before including ifm3d::json.
After this the values can just be assigned and will be converted automatically
Using the user-defined string literals operator""_json
and operator""_json_pointer
ambiguity errors will occur since by default nlohmann::json currently places it's operator""_json
and operator""_json_pointer
into the global namespace. To solve this nlohman::json can be configured to place them into the nlohmann namespace by defining
before including it (see the nlohmann::json doc for more details).
After this the correct namespaces can always be brought into scope when needed, but some care needs to be given to never bring both into the same scope, e.g. the following WILL NOT WORK:
To counteract this, the namspaces can be brought into smaller scopes, the following will all be valid