anystring2json()

anystring2json()#

Converts a given string into a JSON object, supporting various formats including arrays and objects. Returns NULL if parsing fails.

Prototype

json_t *anystring2json(
    const char *bf,
    size_t len,
    BOOL verbose
);

Parameters

Key

Type

Description

bf

const char *

The input string to be converted into a JSON object.

len

size_t

The length of the input string.

verbose

BOOL

If TRUE, logs errors when parsing fails.


Return Value

Returns a json_t * representing the parsed JSON object, or NULL if parsing fails.

Notes

Uses json_loadb() with JSON_DECODE_ANY to support multiple JSON formats. If verbose is TRUE, logs errors when parsing fails.

Prototype

// Not applicable in JS

Prototype

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