DAW JSON Link
Mapping Types

The highlighted mappings below are in the daw::json namespace.

<tt>json_link</tt>

Uses deduced type mappings to determine the mapping type to use. This is also useful in systems with generic types or reflection(future or simulated). The daw_json_link_describe.h(Uses Boost.Describe for class members) and daw_json_boost_pfr_mapping.h(Uses Boost PFR library to get type members) use this mapping type.

<tt>json_array</tt>

Maps JSON arrays to C++ container types.

<tt>json_sized_array</tt>

Maps JSON arrays/size member to C++ container types. This allows easier mapping to types like unique_ptr. Precautions should be taken that the input is trusted or validated in the Constructor type to prevent resource exhaustion.

<tt>json_boolean</tt>

Maps JSON boolean values to C++ boolean/integral types.

<tt>json_class</tt>

Maps JSON objects/types to C++ types with a daw::json::json_data_contract mapping

<tt>json_custom</tt>

Maps JSON strings/literals to C++ types that don't fit.

<tt>json_custom_lit</tt>

A helper for json_custom for mapping to the non-string types

<tt>json_date</tt>

Maps JSON strings in iso8601 timestamp to values to C++ std::chrono::time_point types.

<tt>json_key_value</tt>

Maps JSON objects to C++ containers like maps or vector of pairs.

<tt>json_key_value_array</tt>

Maps JSON array of objects with key/value members to C++ containers

<tt>json_nullable</tt>

Maps JSON values that can be null to Nullable C++ std::optional or pointer like types. The _null variants of other mappings can help with this. Types are required to be Nullable via daw::json::concepts::nullable_value_traits<T>.

<tt>json_number</tt>

Maps JSON number values to C++ arithmetic/bool/enum types.

<tt>json_checked_number</tt>

Maps JSON number values to C++ arithmetic/bool/enum types but the value is checked for narrowing.

<tt>json_raw</tt>

Maps and JSON value to a C++ type. The constructor must take a character/size range and to_json_data returns raw JSON.

<tt>json_string</tt>

Maps JSON string values to C++ string types. The string type will need to own the character range they construct(no string_view).

<tt>json_string_raw</tt>

Maps JSON string values to C++ string types without processing. This allows for string_view mappings.

<tt>json_tuple</tt>

Maps JSON tuples/arrays/heterogeneous arrays to C++ class types. This requires that the order is significant. This is useful to save space because member names are not needed.

<tt>json_value</tt>

General-purpose mapping for JSON values where the type may not be predetermined.

<tt>json_variant</tt>

Maps JSON values that may be one of several types to C++ type(s). Because there is no logic specified to determine the type, only one each of JSON string, boolean, object, number, or array are allowed.

<tt>json_tagged_variant</tt>

Maps JSON values that may be one of serveral types to C++ type(s). A switcher type that inspects another member to determine which alternative is required.

<tt>json_intrusive_variant</tt>

Maps JSON values that may be one of serveral types to C++ type(s). A switcher type that inspects a sub member to determine which alternative is required.

Understanding _null and _no_name Variants

Nullable mappings end in <tt>_null</tt>

The _null variant allows the mapped value to be nullable. Useful when the JSON field may or may not be present. Maps to std::optional in C++, effectively allowing an absence of the value.

Unnamed mappings end in <tt>_no_name</tt>

The _no_name variant implies the JSON field does not have a named key in the serialized output. Typically used for JSON arrays or when the field names are not necessary. These mappings provide robust and flexible ways to handle different JSON structures and types seamlessly within C++ using daw_json_link.

Unnamed nullable mappings <tt>_null_no_name</tt>

The _null_no_name variants combine a nullable type without a name.