---@meta cjson

--------------------------------------------------------------------------------
-- lua-cjson C module
--------------------------------------------------------------------------------

---@alias cjson_bool_option boolean|'on'|'off'
---@alias cjson_invalid_number_option boolean|'on'|'off'|'null'

---@class cjson*
---@field null lightuserdata JSON null Sentinel value
---@field empty_array lightuserdata Empty array sentinel value
---@field array_mt table array metatable
---@field empty_array_mt table empty array metatable
---@field _NAME string module name
---@field _VERSION string version
---@type cjson*
local M = {}

--- Create a new cjson module table that is configured independently.
---@return cjson* module New module table
function M.new() end

--- Encode Lua values ​​to JSON.
---@param value any Lua value
---@return string json JSON text
function M.encode(value) end

--- Decode JSON text.
---@param json string JSON text
---@return any value Lua value
function M.decode(json) end

--- Configure whether an empty table is encoded as an object.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.encode_empty_table_as_object(value) end

--- Configure whether the decoded array comes with `array_mt`.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.decode_array_with_array_mt(value) end

--- Configure whether the decoder allows comments.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.decode_allow_comment(value) end

--- Configure sparse array encoding strategy.
---@param convert? cjson_bool_option Whether to convert an extremely sparse array into an object
---@param ratio? integer Sparse scale threshold
---@param safe? integer Safe array maximum subscript
---@return boolean convert current convert value
---@return integer ratio current ratio value
---@return integer safe current safe value
function M.encode_sparse_array(convert, ratio, safe) end

--- Configure encoding maximum nesting depth.
---@param depth? integer Depth
---@return integer depth current depth
function M.encode_max_depth(depth) end

--- Configure decoding maximum nesting depth.
---@param depth? integer Depth
---@return integer depth current depth
function M.decode_max_depth(depth) end

--- Configure numeric encoding precision.
---@param precision? integer precision, 1 to 16
---@return integer precision Current precision
function M.encode_number_precision(precision) end

--- Configure whether to retain the encoding buffer.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.encode_keep_buffer(value) end

--- Configure the way to encode illegal numbers such as NaN/Infinity.
---@param value? cjson_invalid_number_option Options
---@return boolean|string value current value
function M.encode_invalid_numbers(value) end

--- Configure whether the decoder accepts illegal numbers such as NaN/Infinity.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.decode_invalid_numbers(value) end

--- Configure whether to escape forward slashes.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.encode_escape_forward_slash(value) end

--- Configure whether to skip unsupported value types when encoding.
---@param value? cjson_bool_option Options
---@return boolean enabled current value
function M.encode_skip_unsupported_value_types(value) end

--- Configure formatted indentation string.
---@param indent? string Indent the string; an empty string means no indentation
---@return string indent Current indented string
function M.encode_indent(indent) end

return M
