Unlike "decode", encoding leaves both the key/value on the stack before descending. This leaves no spare room for luaL_error() in case the depth check or lua_checkstack() fails. Allocate an extra stack slot to ensure there is always room for luaL_error() in json_check_encode_depth(). Note: this would not have caused a crash or fault due to the EXTRA_STACK slot reserve, but it was a misuse of the Lua C API.
Return boolean values from configuration functions to simplify usage in the common case. Eg,: if not cjson.encode_invalid_numbers() then .. end