Updated: October 28, 2024 |
Add whitespace to the JSON encoder before the next name, value, or {, }, [, or ] character
#include <sys/json.h>
void json_encoder_add_whitespace(json_encoder_t *encoder, bool newline, int spaces);
For situations where the JSON being generated needs to be more readable, whitespace can be added with this function. This function allows a newline and any number of spaces to be inserted before any subsequent name, value, bracket, or brace is appended to the JSON buffer. This call must be repeated any time whitespace is wanted.
This call has no effect on an encoder instance 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.