Updated: April 19, 2023 |
Reserve space for a given number of bytes in the JSON encoder's buffer
#include <sys/json.h>
json_encoder_error_t json_encoder_reserve_space(json_encoder_t *encoder, int length);
Reserving space can speed up encoding if it is known in advance that a large amount of space is required. If json_encoder_access_buffer() is used to obtain a pointer that allows additional data to be written at the end of the JSON string, json_encoder_reserve_space() can be used to ensure that there is space for the data.
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.