![]() |
PIP 5.6.1
Platform-Independent Primitives
|
Generic JSON serialization helpersThis file provides template functions for serializing and deserializing various types to and from PIJSON format. More...
#include "pijson.h"Functions | |
| template<typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0> | |
| PIJSON | piSerializeJSON (const T &v) |
| Serializes enum values as JSON numbers. | |
| template<typename T , typename std::enable_if<!std::is_enum< T >::value, int >::type = 0, typename std::enable_if< std::is_arithmetic< T >::value, int >::type = 0> | |
| PIJSON | piSerializeJSON (const T &v) |
| Serializes arithmetic values as JSON scalars. More... | |
| PIJSON | piSerializeJSON (const PIJSON &v) |
| Returns JSON node unchanged. | |
| template<> | |
| PIJSON | piSerializeJSON (const PIVariant &v) |
| Serializes PIVariant as the matching scalar JSON node. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const complex< T > &v) |
| Serializes complex number as array [real, imag]. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIFlags< T > &v) |
| Serializes PIFlags as an integer mask. | |
| template<> | |
| PIJSON | piSerializeJSON (const PIString &v) |
| Serializes PIString as JSON string. | |
| template<> | |
| PIJSON | piSerializeJSON (const PIConstChars &v) |
| Serializes PIConstChars as JSON string. | |
| template<> | |
| PIJSON | piSerializeJSON (const PIByteArray &v) |
| Serializes PIByteArray as Base64 string. | |
| template<> | |
| PIJSON | piSerializeJSON (const PISystemTime &v) |
Serializes PISystemTime as object with fields s and ns. | |
| template<> | |
| PIJSON | piSerializeJSON (const PITime &v) |
Serializes PITime as object with fields h, m, s and z. | |
| template<> | |
| PIJSON | piSerializeJSON (const PIDate &v) |
Serializes PIDate as object with fields y, M and d. | |
| template<> | |
| PIJSON | piSerializeJSON (const PIDateTime &v) |
Serializes PIDateTime as object with fields y, M, d, h, m, s and z. | |
| template<> | |
| PIJSON | piSerializeJSON (const PINetworkAddress &v) |
| Serializes PINetworkAddress as string. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIPoint< T > &v) |
Serializes PIPoint as object with fields x and y. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PILine< T > &v) |
Serializes PILine as object with fields p0 and p1. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIRect< T > &v) |
Serializes PIRect as object with fields bl and tr. | |
| template<typename T1 , typename T2 > | |
| PIJSON | piSerializeJSON (const PIPair< T1, T2 > &v) |
| Serializes PIPair as two-element array. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIVector< T > &v) |
| Serializes PIVector as JSON array. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIDeque< T > &v) |
| Serializes PIDeque as JSON array. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIVector2D< T > &v) |
Serializes PIVector2D as object with rows, cols and flattened mat. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PISet< T > &v) |
| Serializes PISet as JSON array. | |
| template<typename K , typename T > | |
| PIJSON | piSerializeJSON (const PIMap< K, T > &v) |
| Serializes PIMap as JSON object with stringified keys. | |
| template<typename T > | |
| PIJSON | piSerializeJSON (const PIMathVector< T > &v) |
| Serializes PIMathVector as JSON array. | |
| template<uint Size, typename T > | |
| PIJSON | piSerializeJSON (const PIMathVectorT< Size, T > &v) |
| Serializes fixed-size PIMathVectorT as JSON array. | |
| template<typename T , typename std::enable_if< std::is_enum< T >::value, int >::type = 0> | |
| void | piDeserializeJSON (T &v, const PIJSON &js) |
| Deserializes enum value from JSON number. | |
| template<typename T , typename std::enable_if<!std::is_enum< T >::value, int >::type = 0, typename std::enable_if< std::is_arithmetic< T >::value, int >::type = 0> | |
| void | piDeserializeJSON (T &v, const PIJSON &js) |
| Deserializes arithmetic value from JSON scalar. More... | |
| void | piDeserializeJSON (PIJSON &v, const PIJSON &js) |
| Copies JSON node as-is. | |
| template<> | |
| void | piDeserializeJSON (PIVariant &v, const PIJSON &js) |
| Extracts scalar value from JSON node into PIVariant. | |
| template<typename T > | |
| void | piDeserializeJSON (complex< T > &v, const PIJSON &js) |
| Deserializes complex number from array [real, imag]. | |
| template<typename T > | |
| void | piDeserializeJSON (PIFlags< T > &v, const PIJSON &js) |
| Deserializes PIFlags from integer mask. | |
| template<> | |
| void | piDeserializeJSON (PIString &v, const PIJSON &js) |
| Deserializes PIString from JSON string representation. | |
| template<> | |
| void | piDeserializeJSON (PIByteArray &v, const PIJSON &js) |
| Deserializes PIByteArray from Base64 string. | |
| template<> | |
| void | piDeserializeJSON (PISystemTime &v, const PIJSON &js) |
Deserializes PISystemTime from object with fields s and ns. | |
| template<> | |
| void | piDeserializeJSON (PITime &v, const PIJSON &js) |
Deserializes PITime from object with fields h, m, s and z. | |
| template<> | |
| void | piDeserializeJSON (PIDate &v, const PIJSON &js) |
Deserializes PIDate from object with fields y, M and d. | |
| template<> | |
| void | piDeserializeJSON (PIDateTime &v, const PIJSON &js) |
Deserializes PIDateTime from object with fields y, M, d, h, m, s and z. | |
| template<> | |
| void | piDeserializeJSON (PINetworkAddress &v, const PIJSON &js) |
| Deserializes PINetworkAddress from string. | |
| template<typename T > | |
| void | piDeserializeJSON (PIPoint< T > &v, const PIJSON &js) |
Deserializes PIPoint from object with fields x and y. | |
| template<typename T > | |
| void | piDeserializeJSON (PILine< T > &v, const PIJSON &js) |
Deserializes PILine from object with fields p0 and p1. | |
| template<typename T > | |
| void | piDeserializeJSON (PIRect< T > &v, const PIJSON &js) |
Deserializes PIRect from object with fields bl and tr. | |
| template<typename T1 , typename T2 > | |
| void | piDeserializeJSON (PIPair< T1, T2 > &v, const PIJSON &js) |
| Deserializes PIPair from two-element array. | |
| template<typename T > | |
| void | piDeserializeJSON (PIVector< T > &v, const PIJSON &js) |
| Deserializes PIVector from JSON array. | |
| template<typename T > | |
| void | piDeserializeJSON (PIDeque< T > &v, const PIJSON &js) |
| Deserializes PIDeque from JSON array. | |
| template<typename T > | |
| void | piDeserializeJSON (PIVector2D< T > &v, const PIJSON &js) |
Deserializes PIVector2D from object with rows, cols and flattened mat. | |
| template<typename T > | |
| void | piDeserializeJSON (PISet< T > &v, const PIJSON &js) |
| Deserializes PISet from JSON array. | |
| template<typename K , typename T > | |
| void | piDeserializeJSON (PIMap< K, T > &v, const PIJSON &js) |
| Deserializes PIMap from JSON object with stringified keys. | |
| template<typename T > | |
| void | piDeserializeJSON (PIMathVector< T > &v, const PIJSON &js) |
| Deserializes dynamic PIMathVector from JSON array. | |
| template<uint Size, typename T > | |
| void | piDeserializeJSON (PIMathVectorT< Size, T > &v, const PIJSON &js) |
| Deserializes fixed-size PIMathVectorT from JSON array, truncating extra items. | |
Generic JSON serialization helpers
This file provides template functions for serializing and deserializing various types to and from PIJSON format.
|
inline |
Serializes arithmetic values as JSON scalars.
Fallback overload that intentionally fails for unsupported complex types.
|
inline |
Deserializes arithmetic value from JSON scalar.
Fallback overload that intentionally fails for unsupported complex types.