json2gbuf()

json2gbuf()#

The function json2gbuf() serializes a JSON object into a gbuffer_t structure, appending the JSON data to the buffer.

Prototype

gbuffer_t *json2gbuf(
    gbuffer_t *gbuf,
    json_t *jn,
    size_t flags
);

Parameters

Key

Type

Description

gbuf

gbuffer_t *

A pointer to an existing gbuffer_t buffer. If NULL, a new buffer is created.

jn

json_t *

A JSON object to be serialized. The function takes ownership of this parameter.

flags

size_t

Flags controlling the JSON serialization behavior.


Return Value

Returns a pointer to a gbuffer_t containing the serialized JSON data. If an error occurs, NULL is returned.

Notes

The function uses json_dump_callback() to serialize the JSON object into the buffer. If gbuf is NULL, a new buffer is allocated with a default size.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples