json_encoder_set_status()

Set the error status of the JSON encoder

Synopsis:

#include <sys/json.h>
void json_encoder_set_status(json_encoder_t *encoder,
                             json_encoder_error_t status);

Arguments:

encoder
The JSON encoder instance.
status
The new error status (see json_encoder_error_t).

Library:

libjson

Description:

This function sets the error status of the given JSON encoder. Calling this function allows the caller to signal that data cannot be encoded. When in an error state, the encoder will not encode any further data because it may result in invalid JSON.

Note:

It is not possible to set the error status to JSON_ENCODER_OK using this function, as the encoded data may be unreliable. To clear an error status, callers should use json_encoder_cleanup() or json_encoder_reset() (and encode their data from the beginning), or call json_encoder_set_state() to restore the state to a previous good state.