Concord - C Discord API library
A Discord API wrapper library written in C
json-build.h File Reference
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for json-build.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  jsonb
 Handle for building a JSON string. More...
 

Macros

#define JSONB_API   extern
 
#define JSONB_MAX_DEPTH   128
 
#define jsonb_reset(builder)   ((builder)->pos = 0)
 Reset a jsonb handle buffer's position tracker (for streaming purposes) More...
 
#define TRACE(prev, next)   next
 
#define DECORATOR(a)
 
#define STACK_HEAD(b, state)   *(b)->top = (state)
 
#define STACK_PUSH(b, state)   TRACE(*(b)->top, *++(b)->top = (state))
 
#define STACK_POP(b)   TRACE(*(b)->top, DECORATOR(*)--(b)->top)
 
#define BUFFER_COPY_CHAR_STATIC(b, c, _pos, buf, bufsize)
 
#define BUFFER_COPY_STATIC(b, value, len, _pos, buf, bufsize)
 
#define BUFFER_COPY_CHAR_REALLOC(b, c, _pos, p_buf, p_bufsize)
 
#define BUFFER_COPY_REALLOC(b, value, len, _pos, p_buf, p_bufsize)
 
#define JSONB_OBJECT_EXEC(_type, buf, bufsize)
 
#define JSONB_OBJECT_POP_EXEC(_type, buf, bufsize)
 
#define JSONB_KEY_EXEC(_type, buf, bufsize, key, len)
 
#define JSONB_ARRAY_EXEC(_type, buf, bufsize)
 
#define JSONB_ARRAY_POP_EXEC(_type, buf, bufsize)
 
#define JSONB_TOKEN_EXEC(_type, buf, bufsize, token, len)
 
#define JSONB_STRING_EXEC(_type, buf, bufsize, str, len)
 

Typedefs

typedef enum jsonbcode jsonbcode
 json-builder return codes More...
 
typedef struct jsonb jsonb
 Handle for building a JSON string. More...
 

Enumerations

enum  jsonbcode {
  JSONB_OK = 0 , JSONB_END , JSONB_ERROR_NOMEM = -1 , JSONB_ERROR_INPUT = -2 ,
  JSONB_ERROR_STACK = -3 , JSONB_ERROR_OVERFLOW = -4
}
 json-builder return codes More...
 
enum  jsonbstate {
  JSONB_INIT = 0 , JSONB_ARRAY_OR_OBJECT_OR_VALUE = JSONB_INIT , JSONB_OBJECT_KEY_OR_CLOSE , JSONB_OBJECT_VALUE ,
  JSONB_OBJECT_NEXT_KEY_OR_CLOSE , JSONB_ARRAY_VALUE_OR_CLOSE , JSONB_ARRAY_NEXT_VALUE_OR_CLOSE , JSONB_ERROR ,
  JSONB_DONE
}
 json-builder serializing state More...
 

Functions

void jsonb_init (jsonb *builder)
 Initialize a jsonb handle. More...
 
jsonbcode jsonb_object (jsonb *builder, char buf[], size_t bufsize)
 Push an object to the builder. More...
 
jsonbcode jsonb_object_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize)
 jsonb_object() with dynamic buffer More...
 
jsonbcode jsonb_object_pop (jsonb *builder, char buf[], size_t bufsize)
 Pop an object from the builder. More...
 
jsonbcode jsonb_object_pop_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize)
 jsonb_object_pop() with dynamic buffer More...
 
jsonbcode jsonb_key (jsonb *builder, char buf[], size_t bufsize, const char key[], size_t len)
 Push a key to the builder. More...
 
jsonbcode jsonb_key_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, const char key[], size_t len)
 jsonb_key() with dynamic buffer More...
 
jsonbcode jsonb_array (jsonb *builder, char buf[], size_t bufsize)
 Push an array to the builder. More...
 
jsonbcode jsonb_array_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize)
 jsonb_array() with dynamic buffer More...
 
jsonbcode jsonb_array_pop (jsonb *builder, char buf[], size_t bufsize)
 Pop an array from the builder. More...
 
jsonbcode jsonb_array_pop_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize)
 jsonb_array_pop() with dynamic buffer More...
 
jsonbcode jsonb_token (jsonb *builder, char buf[], size_t bufsize, const char token[], size_t len)
 Push a raw JSON token to the builder. More...
 
jsonbcode jsonb_token_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, const char token[], size_t len)
 jsonb_token() with dynamic buffer More...
 
jsonbcode jsonb_bool (jsonb *builder, char buf[], size_t bufsize, int boolean)
 Push a boolean token to the builder. More...
 
jsonbcode jsonb_bool_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, int boolean)
 jsonb_bool() with dynamic buffer More...
 
jsonbcode jsonb_null (jsonb *builder, char buf[], size_t bufsize)
 Push a null token to the builder. More...
 
jsonbcode jsonb_null_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize)
 jsonb_null() with dynamic buffer More...
 
jsonbcode jsonb_string (jsonb *builder, char buf[], size_t bufsize, const char str[], size_t len)
 Push a string token to the builder. More...
 
jsonbcode jsonb_string_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, const char str[], size_t len)
 jsonb_string() with dynamic buffer More...
 
jsonbcode jsonb_number (jsonb *builder, char buf[], size_t bufsize, double number)
 Push a number token to the builder. More...
 
jsonbcode jsonb_number_auto (jsonb *builder, char *p_buf[], size_t *p_bufsize, double number)
 jsonb_number() with dynamic buffer More...
 

Macro Definition Documentation

◆ JSONB_API

#define JSONB_API   extern

◆ JSONB_MAX_DEPTH

#define JSONB_MAX_DEPTH   128

Maximum JSON nesting depth, if default value is unwanted then it should be defined before json-build.h is included:

#define JSONB_MAX_DEPTH 256 #include "json-build.h"

◆ jsonb_reset

#define jsonb_reset (   builder)    ((builder)->pos = 0)

Reset a jsonb handle buffer's position tracker (for streaming purposes)

Note
Should be used in conjunction with JSONB_ERROR_NOMEM if the buffer is meant to be used as a stream
Parameters
builderpointer to the jsonb handle

◆ TRACE

#define TRACE (   prev,
  next 
)    next

◆ DECORATOR

#define DECORATOR (   a)

◆ STACK_HEAD

#define STACK_HEAD (   b,
  state 
)    *(b)->top = (state)

◆ STACK_PUSH

#define STACK_PUSH (   b,
  state 
)    TRACE(*(b)->top, *++(b)->top = (state))

◆ STACK_POP

#define STACK_POP (   b)    TRACE(*(b)->top, DECORATOR(*)--(b)->top)

◆ BUFFER_COPY_CHAR_STATIC

#define BUFFER_COPY_CHAR_STATIC (   b,
  c,
  _pos,
  buf,
  bufsize 
)
Value:
do { \
if ((b)->pos + (_pos) + 1 + 1 > (bufsize)) { \
(buf)[(b)->pos] = '\0'; \
} \
(buf)[(b)->pos + (_pos)++] = (c); \
(buf)[(b)->pos + (_pos)] = '\0'; \
} while (0)
@ JSONB_ERROR_NOMEM
Definition: json-build.h:40

◆ BUFFER_COPY_STATIC

#define BUFFER_COPY_STATIC (   b,
  value,
  len,
  _pos,
  buf,
  bufsize 
)
Value:
do { \
size_t i; \
if ((b)->pos + (_pos) + (len) + 1 > (bufsize)) { \
(buf)[(b)->pos] = '\0'; \
} \
for (i = 0; i < (len); ++i) \
(buf)[(b)->pos + (_pos) + i] = (value)[i]; \
(_pos) += (len); \
(buf)[(b)->pos + (_pos)] = '\0'; \
} while (0)

◆ BUFFER_COPY_CHAR_REALLOC

#define BUFFER_COPY_CHAR_REALLOC (   b,
  c,
  _pos,
  p_buf,
  p_bufsize 
)
Value:
do { \
if ((b)->pos + (_pos) + 1 + 1 > *p_bufsize) { \
char *new_buf = NULL; \
const size_t needed = (b)->pos + (_pos) + 1 + 1; \
size_t new_size = *p_bufsize + (*p_bufsize >> 1); /* 1.5x */ \
if (new_size < needed) new_size = needed; \
if (new_size < *p_bufsize) return JSONB_ERROR_OVERFLOW; \
new_buf = realloc(*p_buf, new_size); \
if (!new_buf) return JSONB_ERROR_NOMEM; \
*p_buf = new_buf; \
*p_bufsize = new_size; \
} \
(*p_buf)[(b)->pos + (_pos)++] = (c); \
(*p_buf)[(b)->pos + (_pos)] = '\0'; \
} while (0)
@ JSONB_ERROR_OVERFLOW
Definition: json-build.h:46

◆ BUFFER_COPY_REALLOC

#define BUFFER_COPY_REALLOC (   b,
  value,
  len,
  _pos,
  p_buf,
  p_bufsize 
)
Value:
do { \
size_t i; \
if ((b)->pos + (_pos) + (len) + 1 > *p_bufsize) { \
char *new_buf = NULL; \
const size_t needed = (b)->pos + (_pos) + (len) + 1; \
size_t new_size = *p_bufsize + (*p_bufsize >> 1); /* 1.5x */ \
if (new_size < needed) new_size = needed; \
if (new_size < *p_bufsize) return JSONB_ERROR_OVERFLOW; \
new_buf = realloc(*p_buf, new_size); \
if (!new_buf) return JSONB_ERROR_NOMEM; \
*p_buf = new_buf; \
*p_bufsize = new_size; \
} \
for (i = 0; i < (len); ++i) \
(*p_buf)[(b)->pos + (_pos) + i] = (value)[i]; \
(_pos) += (len); \
(*p_buf)[(b)->pos + (_pos)] = '\0'; \
} while (0)

◆ JSONB_OBJECT_EXEC

#define JSONB_OBJECT_EXEC (   _type,
  buf,
  bufsize 
)
Value:
enum jsonbstate new_state; \
size_t pos = 0; \
if (b->top - b->stack >= JSONB_MAX_DEPTH) return JSONB_ERROR_STACK; \
switch (*b->top) { \
BUFFER_COPY_CHAR_##_type(b, ',', pos, buf, bufsize); \
/* fall-through */ \
break; \
break; \
new_state = JSONB_DONE; \
break; \
default: \
STACK_HEAD(b, JSONB_ERROR); \
/* fall-through */ \
case JSONB_DONE: \
case JSONB_ERROR: \
} \
BUFFER_COPY_CHAR_##_type(b, '{', pos, buf, bufsize); \
STACK_HEAD(b, new_state); \
STACK_PUSH(b, JSONB_OBJECT_KEY_OR_CLOSE); \
b->pos += pos; \
return JSONB_OK
jsonbstate
json-builder serializing state
Definition: json-build.h:50
@ JSONB_OBJECT_VALUE
Definition: json-build.h:54
@ JSONB_ARRAY_VALUE_OR_CLOSE
Definition: json-build.h:56
@ JSONB_OBJECT_NEXT_KEY_OR_CLOSE
Definition: json-build.h:55
@ JSONB_ARRAY_NEXT_VALUE_OR_CLOSE
Definition: json-build.h:57
@ JSONB_ERROR
Definition: json-build.h:58
@ JSONB_DONE
Definition: json-build.h:59
@ JSONB_OBJECT_KEY_OR_CLOSE
Definition: json-build.h:53
@ JSONB_ARRAY_OR_OBJECT_OR_VALUE
Definition: json-build.h:52
#define JSONB_MAX_DEPTH
Definition: json-build.h:30
@ JSONB_ERROR_INPUT
Definition: json-build.h:42
@ JSONB_ERROR_STACK
Definition: json-build.h:44
@ JSONB_OK
Definition: json-build.h:36

◆ JSONB_OBJECT_POP_EXEC

#define JSONB_OBJECT_POP_EXEC (   _type,
  buf,
  bufsize 
)
Value:
enum jsonbcode code; \
size_t pos = 0; \
switch (*b->top) { \
code = b->stack == b->top - 1 ? JSONB_END : JSONB_OK; \
break; \
default: \
STACK_HEAD(b, JSONB_ERROR); \
/* fall-through */ \
case JSONB_DONE: \
case JSONB_ERROR: \
} \
BUFFER_COPY_CHAR_##_type(b, '}', pos, buf, bufsize); \
STACK_POP(b); \
b->pos += pos; \
return code
jsonbcode
json-builder return codes
Definition: json-build.h:34
@ JSONB_END
Definition: json-build.h:38

◆ JSONB_KEY_EXEC

#define JSONB_KEY_EXEC (   _type,
  buf,
  bufsize,
  key,
  len 
)
Value:
size_t pos = 0; \
switch (*b->top) { \
BUFFER_COPY_CHAR_##_type(b, ',', pos, buf, bufsize); \
/* fall-through */ \
enum jsonbcode ret; \
BUFFER_COPY_CHAR_##_type(b, '"', pos, buf, bufsize); \
ret = _jsonb_escape_##_type(&pos, buf, bufsize, b->pos, key, len); \
if (ret != JSONB_OK) return ret; \
BUFFER_COPY_##_type(b, "\":", 2, pos, buf, bufsize); \
STACK_HEAD(b, JSONB_OBJECT_VALUE); \
} break; \
default: \
STACK_HEAD(b, JSONB_ERROR); \
/* fall-through */ \
case JSONB_DONE: \
} \
b->pos += pos; \
return JSONB_OK

◆ JSONB_ARRAY_EXEC

#define JSONB_ARRAY_EXEC (   _type,
  buf,
  bufsize 
)
Value:
enum jsonbstate new_state; \
size_t pos = 0; \
if (b->top - b->stack >= JSONB_MAX_DEPTH) return JSONB_ERROR_STACK; \
switch (*b->top) { \
BUFFER_COPY_CHAR_##_type(b, ',', pos, buf, bufsize); \
/* fall-through */ \
break; \
break; \
new_state = JSONB_DONE; \
break; \
default: \
STACK_HEAD(b, JSONB_ERROR); \
/* fall-through */ \
case JSONB_DONE: \
case JSONB_ERROR: \
} \
BUFFER_COPY_CHAR_##_type(b, '[', pos, buf, bufsize); \
STACK_HEAD(b, new_state); \
STACK_PUSH(b, JSONB_ARRAY_VALUE_OR_CLOSE); \
b->pos += pos; \
return JSONB_OK

◆ JSONB_ARRAY_POP_EXEC

#define JSONB_ARRAY_POP_EXEC (   _type,
  buf,
  bufsize 
)
Value:
enum jsonbcode code; \
size_t pos = 0; \
switch (*b->top) { \
code = b->stack == b->top - 1 ? JSONB_END : JSONB_OK; \
break; \
default: \
STACK_HEAD(b, JSONB_ERROR); \
/* fall-through */ \
case JSONB_DONE: \
case JSONB_ERROR: \
} \
BUFFER_COPY_CHAR_##_type(b, ']', pos, buf, bufsize); \
STACK_POP(b); \
b->pos += pos; \
return code

◆ JSONB_TOKEN_EXEC

#define JSONB_TOKEN_EXEC (   _type,
  buf,
  bufsize,
  token,
  len 
)
Value:
enum jsonbstate next_state; \
enum jsonbcode code; \
size_t pos = 0; \
switch (*b->top) { \
next_state = JSONB_DONE; \
code = JSONB_END; \
break; \
BUFFER_COPY_CHAR_##_type(b, ',', pos, buf, bufsize); \
/* fall-through */ \
code = JSONB_OK; \
break; \
code = JSONB_OK; \
break; \
default: \
STACK_HEAD(b, JSONB_ERROR); \
/* fall-through */ \
case JSONB_DONE: \
case JSONB_ERROR: \
} \
BUFFER_COPY_##_type(b, token, len, pos, buf, bufsize); \
STACK_HEAD(b, next_state); \
b->pos += pos; \
return code

◆ JSONB_STRING_EXEC

#define JSONB_STRING_EXEC (   _type,
  buf,
  bufsize,
  str,
  len 
)

Typedef Documentation

◆ jsonbcode

typedef enum jsonbcode jsonbcode

json-builder return codes

◆ jsonb

typedef struct jsonb jsonb

Handle for building a JSON string.

Enumeration Type Documentation

◆ jsonbcode

enum jsonbcode

json-builder return codes

Enumerator
JSONB_OK 

no error, operation was a success

JSONB_END 

string is complete, expects no more inputs

JSONB_ERROR_NOMEM 

not enough tokens were provided

JSONB_ERROR_INPUT 

token doesn't match expected value

JSONB_ERROR_STACK 

operation would lead to out of boundaries access

JSONB_ERROR_OVERFLOW 

buffer overflow

◆ jsonbstate

enum jsonbstate

json-builder serializing state

Enumerator
JSONB_INIT 
JSONB_ARRAY_OR_OBJECT_OR_VALUE 
JSONB_OBJECT_KEY_OR_CLOSE 
JSONB_OBJECT_VALUE 
JSONB_OBJECT_NEXT_KEY_OR_CLOSE 
JSONB_ARRAY_VALUE_OR_CLOSE 
JSONB_ARRAY_NEXT_VALUE_OR_CLOSE 
JSONB_ERROR 
JSONB_DONE 

Function Documentation

◆ jsonb_init()

void jsonb_init ( jsonb builder)

Initialize a jsonb handle.

Parameters
builderthe handle to be initialized

◆ jsonb_object()

jsonbcode jsonb_object ( jsonb builder,
char  buf[],
size_t  bufsize 
)

Push an object to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
Returns
jsonbcode value

◆ jsonb_object_auto()

jsonbcode jsonb_object_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize 
)

jsonb_object() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer the JSON buffer size
Returns
jsonbcode value

◆ jsonb_object_pop()

jsonbcode jsonb_object_pop ( jsonb builder,
char  buf[],
size_t  bufsize 
)

Pop an object from the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
Returns
jsonbcode value

◆ jsonb_object_pop_auto()

jsonbcode jsonb_object_pop_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize 
)

jsonb_object_pop() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer the JSON buffer size
Returns
jsonbcode value

◆ jsonb_key()

jsonbcode jsonb_key ( jsonb builder,
char  buf[],
size_t  bufsize,
const char  key[],
size_t  len 
)

Push a key to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
keythe key to be inserted
lenthe key length
Returns
jsonbcode value

◆ jsonb_key_auto()

jsonbcode jsonb_key_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize,
const char  key[],
size_t  len 
)

jsonb_key() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
keythe key to be inserted
lenthe key length
Returns
jsonbcode value

◆ jsonb_array()

jsonbcode jsonb_array ( jsonb builder,
char  buf[],
size_t  bufsize 
)

Push an array to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
Returns
jsonbcode value

◆ jsonb_array_auto()

jsonbcode jsonb_array_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize 
)

jsonb_array() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
Returns
jsonbcode value

◆ jsonb_array_pop()

jsonbcode jsonb_array_pop ( jsonb builder,
char  buf[],
size_t  bufsize 
)

Pop an array from the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
Returns
jsonbcode value

◆ jsonb_array_pop_auto()

jsonbcode jsonb_array_pop_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize 
)

jsonb_array_pop() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
Returns
jsonbcode value

◆ jsonb_token()

jsonbcode jsonb_token ( jsonb builder,
char  buf[],
size_t  bufsize,
const char  token[],
size_t  len 
)

Push a raw JSON token to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
tokenthe token to be inserted
lenthe token length
Returns
jsonbcode value

◆ jsonb_token_auto()

jsonbcode jsonb_token_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize,
const char  token[],
size_t  len 
)

jsonb_token() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
tokenthe token to be inserted
lenthe token length
Returns
jsonbcode value

◆ jsonb_bool()

jsonbcode jsonb_bool ( jsonb builder,
char  buf[],
size_t  bufsize,
int  boolean 
)

Push a boolean token to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
booleanthe boolean to be inserted
Returns
jsonbcode value

◆ jsonb_bool_auto()

jsonbcode jsonb_bool_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize,
int  boolean 
)

jsonb_bool() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
booleanthe boolean to be inserted
Returns
jsonbcode value

◆ jsonb_null()

jsonbcode jsonb_null ( jsonb builder,
char  buf[],
size_t  bufsize 
)

Push a null token to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
Returns
jsonbcode value

◆ jsonb_null_auto()

jsonbcode jsonb_null_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize 
)

jsonb_null() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
Returns
jsonbcode value

◆ jsonb_string()

jsonbcode jsonb_string ( jsonb builder,
char  buf[],
size_t  bufsize,
const char  str[],
size_t  len 
)

Push a string token to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
strthe string to be inserted
lenthe string length
Returns
jsonbcode value

◆ jsonb_string_auto()

jsonbcode jsonb_string_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize,
const char  str[],
size_t  len 
)

jsonb_string() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
strthe string to be inserted
lenthe string length
Returns
jsonbcode value

◆ jsonb_number()

jsonbcode jsonb_number ( jsonb builder,
char  buf[],
size_t  bufsize,
double  number 
)

Push a number token to the builder.

Parameters
builderthe builder initialized with jsonb_init()
bufthe JSON buffer
bufsizethe JSON buffer size
numberthe number to be inserted
Returns
jsonbcode value

◆ jsonb_number_auto()

jsonbcode jsonb_number_auto ( jsonb builder,
char *  p_buf[],
size_t *  p_bufsize,
double  number 
)

jsonb_number() with dynamic buffer

Parameters
builderthe builder initialized with jsonb_init()
p_bufpointer to the JSON buffer
p_bufsizepointer to the JSON buffer size
numberthe number to be inserted
Returns
jsonbcode value