#include <json-utils.hh>
Static Public Member Functions | |
static void | from_json (const json &json, std::optional< T > &t) |
Convert a JSON type to an optional<T> treating null as std::nullopt . | |
static void | to_json (json &json, const std::optional< T > &t) |
Convert an optional type to a JSON type treating std::nullopt as null . | |
This "instance" is widely requested, see https://github.com/nlohmann/json/issues/1749, but momentum has stalled out. Writing there here in Nix as a stop-gap.
We need to make sure the underlying type does not use null
for this to round trip. We do that with a static assert.