JsoNeat
Some JSON parse/iterate C++ classes build on top of Jsmn
Loading...
Searching...
No Matches
jsoneat::to_json::cbuf Namespace Reference

Serialize objects to JSON using char array buffers. For smaller objects which fit into such a buffer. More...

Functions

int to_json_val (char *dst, size_t dst_size, bool val)
 Print value of a JSON key/value pair and append trailing comma.
 
int to_json_val (char *dst, size_t dst_size, int val)
 Print value of a JSON key/value pair and append trailing comma.
 
int to_json_val (char *dst, size_t dst_size, long val)
 Print value of a JSON key/value pair and append trailing comma.
 
int to_json_val (char *dst, size_t dst_size, long long val)
 Print value of a JSON key/value pair and append trailing comma.
 
int to_json_val (char *dst, size_t dst_size, unsigned val)
 Print value of a JSON key/value pair and append trailing comma.
 
int to_json_val (char *dst, size_t dst_size, float val)
 Print value of a JSON key/value pair and append trailing comma.
 
template<size_t SIZE>
int to_json_val (char *dst, size_t dst_size, const char(&val)[SIZE])
 Print value of a JSON key/value pair and append trailing comma.
 
template<class C , typename std::enable_if< std::is_class_v< C > >::type * = nullptr>
int to_json_val (char *dst, size_t dst_size, const C &val, bool append_comma=true)
 Print value of a JSON key/value pair and append trailing comma.
 
template<typename T , size_t SIZE>
int to_json_val (char *dst, size_t dst_size, const std::array< T, SIZE > &val, bool append_comma=true)
 Print value of a JSON key/value pair and append trailing comma.
 
template<typename T , size_t SIZE>
int to_json_val (char *dst, size_t dst_size, const T(&val)[SIZE], bool append_comma=true)
 Print value of a JSON key/value pair and append trailing comma.
 
template<class T >
int to_json_kvp (char *dst, size_t dst_size, const jsoneat::KvPair< T > kvp)
 Print key and value of a JSON key/value pair and append trailing comma.
 
template<size_t SIZE>
int to_json_kvp (char *dst, size_t dst_size, const jsoneat::KvPair< char[SIZE]> kvp)
 Print key and value of a JSON key/value pair and append trailing comma.
 
template<typename T , typename ... Args>
int to_json_args (char *dst, size_t dst_size, const T &pair, Args ... args)
 

Detailed Description

Serialize objects to JSON using char array buffers. For smaller objects which fit into such a buffer.

Function Documentation

◆ to_json_args()

template<typename T , typename ... Args>
int jsoneat::to_json::cbuf::to_json_args ( char *  dst,
size_t  dst_size,
const T &  pair,
Args ...  args 
)
Template Parameters
TPrints an argument-list of key/value pairs as JSON
Argslist of types which should each be an instance of struct template jsoneat::KvPair
Parameters
dstoutput buffer
dst_sizeoutput buffer size
pairFirst key/value pair in argument list
argsRest of argument list
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_kvp() [1/2]

template<size_t SIZE>
int jsoneat::to_json::cbuf::to_json_kvp ( char *  dst,
size_t  dst_size,
const jsoneat::KvPair< char[SIZE]>  kvp 
)

Print key and value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
kvpinput key/value pair. Value is C style char array.
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_kvp() [2/2]

template<class T >
int jsoneat::to_json::cbuf::to_json_kvp ( char *  dst,
size_t  dst_size,
const jsoneat::KvPair< T >  kvp 
)

Print key and value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
kvpinput key/value pair
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [1/10]

int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
bool  val 
)
inline

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [2/10]

template<class C , typename std::enable_if< std::is_class_v< C > >::type * = nullptr>
int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
const C &  val,
bool  append_comma = true 
)

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value, which is an object
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [3/10]

template<size_t SIZE>
int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
const char(&)  val[SIZE] 
)

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [4/10]

template<typename T , size_t SIZE>
int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
const std::array< T, SIZE > &  val,
bool  append_comma = true 
)

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value, which is a std::array
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [5/10]

template<typename T , size_t SIZE>
int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
const T(&)  val[SIZE],
bool  append_comma = true 
)

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value, which is a C style array
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [6/10]

int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
float  val 
)
inline

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [7/10]

int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
int  val 
)
inline

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [8/10]

int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
long long  val 
)
inline

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [9/10]

int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
long  val 
)
inline

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written

◆ to_json_val() [10/10]

int jsoneat::to_json::cbuf::to_json_val ( char *  dst,
size_t  dst_size,
unsigned  val 
)
inline

Print value of a JSON key/value pair and append trailing comma.

Parameters
dstoutput buffer
dst_sizeoutput buffer size
valinput value
Returns
Like snprintf(3), the number of characters needed. If smaller than dst_size, the output was fully written