48#if __has_include( "nfx/datatypes/Int128.h" )
50# include "nfx/datatypes/Int128.h"
53namespace nfx::serialization::json::detail
61namespace nfx::serialization::json
75 static void serialize(
const nfx::datatypes::Int128& obj, nfx::json::Builder& builder )
77 std::string value = obj.toString();
78 builder.write( value );
88 static void fromDocument(
const Document& doc, nfx::datatypes::Int128& obj )
90 if( doc.is<std::string>(
"" ) )
92 auto val = doc.get<std::string>(
"" );
93 if( val.has_value() && !val.value().empty() )
95 if( !nfx::datatypes::Int128::fromString( val.value(), obj ) )
97 throw std::runtime_error{
"Invalid Int128 format: unable to parse string representation" };
111#if __has_include( "nfx/datatypes/Decimal.h" )
113# include "nfx/datatypes/Decimal.h"
116namespace nfx::serialization::json::detail
124namespace nfx::serialization::json
138 static void serialize(
const nfx::datatypes::Decimal& obj, nfx::json::Builder& builder )
140 std::string value = obj.toString();
141 builder.write( value );
151 static void fromDocument(
const Document& doc, nfx::datatypes::Decimal& obj )
153 if( doc.is<std::string>(
"" ) )
155 auto val = doc.get<std::string>(
"" );
156 if( val.has_value() && !val.value().empty() )
158 if( !nfx::datatypes::Decimal::fromString( val.value(), obj ) )
160 throw std::runtime_error{
"Invalid Decimal format: unable to parse string representation" };
Templated JSON serializer with compile-time type mapping.
Serialization traits template (forward declaration).
static void fromDocument(const Document &doc, T &obj)
Convert Document to object (deserialization).
Identifies types from nfx:: namespaces that have SerializationTraits.