json_encoder_buffer()

Get a read-only pointer to the JSON encoder's data buffer

Synopsis:

#include <sys/json.h>
const char* json_encoder_buffer(const json_encoder_t *encoder);

Arguments:

encoder
The JSON encoder instance.

Library:

libjson

Description:

This function returns a read-only pointer to the buffer holding the encoded data for the given JSON encoder. A valid pointer is returned if there have been no errors and all objects have had their encoding properly ended. The pointer returned is not valid after any subsequent json_encoder_*() calls.

Note:

This call is not applicable to encoder instances obtained from json_decoder_get_encoder(), since JSON items encoded with these encoders are added directly to the decoder tree rather than into a JSON-formatted buffer.

Returns:

A read-only pointer to the encoded buffer, or NULL if an error status exists in the encoder, the encoded data is incomplete, or the encoder instance was obtained from json_decoder_get_encoder().