ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
JsonOptional.hpp File Reference

nlohmann::json support for std::optional<T>. More...

#include <nlohmann/json.hpp>
#include <optional>
#include <string_view>

Go to the source code of this file.

Classes

struct  nlohmann::adl_serializer< std::optional< T > >
 

Namespaces

namespace  nlohmann
 
namespace  ppforest2
 Binarization strategies for multiclass-to-binary reduction.
 
namespace  ppforest2::serialization
 JSON serialization and deserialization for ppforest2 models.
 

Functions

bool ppforest2::serialization::has_value (nlohmann::json const &j, std::string_view key)
 True iff j has a non-null value at key.
 

Detailed Description

nlohmann::json support for std::optional<T>.

Include this header alongside <nlohmann/json.hpp> to enable transparent JSON conversion for std::optional fields:

j["key"] = std::optional<int>(42); // writes 42
j["key"] = std::optional<int>{}; // writes null
auto opt = j["key"].get<std::optional<int>>(); // reads back