json_encoder_reset()

Reset a JSON encoder instance

Synopsis:

#include <sys/json.h>
void json_encoder_reset(json_encoder_t *encoder,
                        int offset);

Arguments:

encoder
The JSON encoder instance.
offset
The offset within the encoder's buffer to position the encoder at. Typically this would be 0, but providing another value allows callers to encode multiple data sets in a single buffer.

Library:

libjson

Description:

This function resets the given JSON encoder for encoding new data. It is typically better to call json_encoder_reset() rather than json_encoder_cleanup() when performing multiple encoding operations, to reduce memory allocation operations. This is because the encoder's buffer will automatically grow to accommodate the largest size required.