gbuf2json()

gbuf2json()#

Converts a gbuffer_t * containing JSON data into a json_t * object. The function consumes the input buffer and returns a parsed JSON object.

Prototype

json_t *gbuf2json(
    gbuffer_t *gbuf,  // WARNING gbuf own and data consumed
    int verbose       // 1 log, 2 log+dump
);

Parameters

Key

Type

Description

gbuf

gbuffer_t *

The input gbuffer_t * containing JSON data. This buffer is consumed and should not be used after calling this function.

verbose

int

Logging verbosity level: 1 logs errors, 2 logs errors and dumps the buffer content.


Return Value

Returns a json_t * object if parsing is successful. Returns NULL if parsing fails.

Notes

The function uses json_load_callback() to parse the JSON data from the buffer. If parsing fails, an error is logged based on the verbose level.

Prototype

// Not applicable in JS

Prototype

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