json_check_refcounts()
#
Checks the reference counts of a JSON object and its nested elements, ensuring they do not exceed a specified limit.
Prototype
int json_check_refcounts(
json_t *jn, // not owned
int max_refcount,
int *result // firstly initalize to 0
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
The JSON object to check. It is not owned by the function. |
|
|
The maximum allowed reference count for any JSON element. If set to a positive value, elements exceeding this limit will be reported. |
|
|
Pointer to an integer that stores the result of the check. It must be initialized to 0 before calling the function. |
Return Value
Returns 0 if all reference counts are within the allowed limit. Returns a negative value if any reference count is invalid or exceeds the specified limit.
Notes
This function recursively checks all elements in the JSON object, including arrays and nested objects. If max_refcount
is greater than 0, elements exceeding this limit will be logged as errors.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples