vjsnprintf()

Updated: October 28, 2024

Write JSON data to a character array, up to a given number of characters (varargs)

Synopsis:

#include <sys/json.h>
int vjsnprintf(char *buffer,
               int len,
               const char *format,
               va_list args);

Arguments:

buffer
A pointer to a buffer to store the formatted string.
len
The maximum number of characters to store in the buffer, including a terminating null character. If this value is at least one, the buffer will be null-terminated.
format
A string that specifies the format of the output. This string determines what additional arguments you need to provide.
args
A variable-argument list of the additional arguments, which you must have initialized with the va_start() macro.

Library:

libjson

Description:

The vjsnprintf() function formats JSON data based on the format string and stores the result in buffer. The maximum number of characters written, including a terminating null character, is given by len.

The vjsnprintf() function is a “varargs” version of jsnprintf(). For details on what the format-specifier string can contain, including conversion specifiers, see jsnprintf().

Returns:

The number of characters that were written to the output buffer or that would have been written had it been large enough, not including the terminating null character. -1 is returned if the format-specifier string is invalid.

  翻译: