create_json_record()

create_json_record()#

create_json_record() initializes a JSON object based on a predefined schema, setting default values for each field.

Prototype

json_t *create_json_record(
    hgobj gobj,
    const json_desc_t *json_desc
);

Parameters

Key

Type

Description

gobj

hgobj

A handle to the GObj instance, used for logging errors.

json_desc

const json_desc_t *

A pointer to an array of json_desc_t structures defining the JSON schema.


Return Value

A newly allocated json_t * object containing the initialized JSON structure, or NULL on failure.

Notes

[‘The json_desc_t structure must be properly terminated with a NULL entry.’, ‘The function supports various JSON types including string, integer, real, boolean, null, object, and array.’, ‘If an unknown type is encountered, an error is logged using gobj_log_error().’]

Prototype

// Not applicable in JS

Prototype

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