jn2integer()

jn2integer()#

jn2integer() converts a JSON value to an integer, handling different JSON types such as strings, booleans, and numbers.

Prototype

json_int_t jn2integer(json_t *jn_var);

Parameters

Key

Type

Description

jn_var

json_t *

The JSON value to be converted to an integer.


Return Value

Returns the integer representation of the JSON value. If the value is a string, it is parsed as an integer. If it is a boolean, true is converted to 1 and false to 0. If the value is null, it returns 0.

Notes

This function supports parsing integers from strings with decimal, octal (prefix 0), and hexadecimal (prefix x or X) formats.

Prototype

// Not applicable in JS

Prototype

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