jn2string()

jn2string()#

jn2string() converts a JSON value into a dynamically allocated string representation, ensuring proper memory management.

Prototype

char *jn2string(json_t *jn_var);

Parameters

Key

Type

Description

jn_var

json_t *

The JSON value to be converted into a string.


Return Value

A dynamically allocated string representation of the JSON value. The caller must free the returned string using GBMEM_FREE().

Notes

If jn_var is a string, it returns a duplicate of the string. If it is an integer or real, it converts the value to a string. If it is a boolean, it returns “1” for true and “0” for false.

Prototype

// Not applicable in JS

Prototype

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