json_encoder_add_whitespace()

QNX SDP8.0JSON Library ReferenceAPIDeveloper

Add whitespace to the JSON encoder before the next name, value, or {, }, [, or ] character

Synopsis:

#include <sys/json.h>
void json_encoder_add_whitespace(json_encoder_t *encoder,
                                 bool newline,
                                 int spaces)

Arguments:

encoder
The JSON encoder instance.
newline
Pass true to have a newline character inserted before any spaces are inserted.
spaces
The number of spaces to insert when appropriate.

Library:

libjson

Description:

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.

Note:

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.

Page updated: