json_encoder_add_from_decoder()

Add items from a JSON decoder to the JSON encoder

Synopsis:

#include <sys/json.h>
json_encoder_error_t json_encoder_add_from_decoder(
                                                  json_encoder_t *encoder,
                                                  const char *name,
                                                  json_decoder_t *decoder,
                                                  const char *prop_name);

Arguments:

encoder
The JSON encoder instance.
name
The name of the encoder property if the items are being added to an object, or NULL if they're being added to an array or if the property was already named with json_encoder_add_property_name().
decoder
The JSON decoder, which must be positioned at the appropriate node.
prop_name
The name of the property node the items will be added from, or NULL to add the items from the node at the current position.

Library:

libjson

Description:

This function adds the items from the given or current property node in the given JSON decoder to the specified or current object or array in the given JSON encoder. This allows data that was previously decoded to be re-encoded.

The state of the decoder is not changed; when the function call completes, the decoder is in the same state as before the call.

Returns:

JSON_ENCODER_OK
Success.
JSON_ENCODER_NO_MEMORY
There is not enough memory to perform the operation.
JSON_ENCODER_UNEXPECTED_NAME
A name was provided for a property that was already named, or for an element in an array, which can't accept a name.
JSON_ENCODER_MISSING_PROPERTY_NAME
No name was provided for the property.
JSON_ENCODER_NOT_FOUND
The node in the decoder does not exist.
JSON_ENCODER_INVALID_VALUE
The node value in the decoder is not valid.