|
core-adapters 0.1.2
Third-party adapters for snicholls-core: nanobind helpers, nlohmann/json hooks, the snicholls_core Python package
|
snicholls::json_error and the nlohmann/json adapter layer: shared by every adapter.
More...
Go to the source code of this file.
Classes | |
| struct | snicholls::json_error |
| A JSON value that does not convert to or from a core type. More... | |
snicholls::json_error and the nlohmann/json adapter layer: shared by every adapter.
include/snicholls/core_adapters/nlohmann/, behind their own CMake target snicholls::core_json.Include the adapter for the type you serialise - time_json.hpp, uuid_json.hpp, decimal_json.hpp, secret_json.hpp - and nlohmann::json j = value; / j.get<T>() work through argument-dependent lookup. This header is what they share: the error type and the rule that no nlohmann exception escapes an adapter.
snicholls::to_json / snicholls::from_json overloads in the sibling adapters.from_json throws snicholls::json_error, never a nlohmann::json::exception. Tests prove it for every adapter and every kind of JSON value.JSON_ImplicitConversions=OFF; convert with j.get<T>(). The adapters do not depend on the setting.snicholls::json_error (a std::runtime_error), with a message naming the type and quoting at most 64 characters of the offending text (never for secret, whose text is never quoted).std::string assignment.snicholls::core_json (= snicholls::core + nlohmann_json::nlohmann_json, the vendored third_party/nlohmann_json at v3.12.0 unless the consumer already defines that target). Enabled by CORE_ADAPTERS_WITH_NLOHMANN (ON by default).snicholls::core_json is not installed: consume it from the source tree (add_subdirectory).Definition in file json.hpp.