json_encoder_set_state()

Set the state of the JSON encoder

Synopsis:

#include <sys/json.h>
json_encoder_error_t json_encoder_set_state(json_encoder_t *encoder,
                                            json_encoder_state_t *state);

Arguments:

encoder
The JSON encoder instance.
state
A pointer to a JSON encoder state instance containing the new state.

Library:

libjson

Description:

This function restores the given JSON encoder to a state previously obtained with json_encoder_get_state().

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:

JSON_ENCODER_OK
Success.
JSON_ENCODER_INVALID_STATE
The given state is not valid.
JSON_ENCODER_NOT_SUPPORTED
The encoder instance was obtained from json_decoder_get_encoder().