qtty-cpp 0.4.5
Header-only C++ wrapper for qtty
Loading...
Searching...
No Matches
qtty::derived_serialization Namespace Reference

Functions

template<typename Tag >
std::string to_json (const Quantity< Tag > &q)
 Serialize a compound quantity as JSON.
 
template<typename T >
Quantity< typename ExtractTag< T >::type > from_json (std::string_view json)
 Deserialize a JSON string into a compound quantity.
 

Function Documentation

◆ from_json()

template<typename T >
Quantity< typename ExtractTag< T >::type > qtty::derived_serialization::from_json ( std::string_view  json)

Deserialize a JSON string into a compound quantity.

Template Parameters
TCompoundTag or Quantity<CompoundTag> type.
Parameters
jsonJSON input string view.
Returns
Deserialized compound quantity, converted to requested target units.

Definition at line 173 of file serialization.hpp.

References qtty::check_status(), qtty::is_angular_v, and qtty_derived_from_json().

◆ to_json()

template<typename Tag >
std::string qtty::derived_serialization::to_json ( const Quantity< Tag > &  q)

Serialize a compound quantity as JSON.

Template Parameters
TagCompoundTag type of the quantity.
Parameters
qSource compound quantity.
Returns
JSON string.

Definition at line 154 of file serialization.hpp.

References qtty::check_status(), qtty::serialization::from_owned_c(), qtty::is_angular_v, and qtty_derived_to_json().