summaryrefslogtreecommitdiff
path: root/lua_cjson.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* feature: applied Jiale Zhi's patch to add the new config function ↵2.1.0.1Yichun Zhang (agentzh)2014-02-181-1/+13
| | | | encode_empty_table_as_object so that we can encode empty Lua tables into empty JSON arrays.
* Use Javascript compat values for Infinity/NaNMark Pulford2012-03-041-4/+12
| | | | | Use Javascript compatible values for Infinity/NaN when encoding invalid numbers.
* Bump version to 2.1develMark Pulford2012-03-041-1/+1
|
* Add cjson.safe module to suppress exceptionsMark Pulford2012-03-041-0/+58
| | | | Add cjson.safe module to suppress exceptions during JSON conversions.
* Ignore DISABLE_INVALID_NUMBERS with builtin fpconvMark Pulford2012-03-041-12/+14
|
* Bump version to 2.0develMark Pulford2012-03-041-1/+1
| | | | | Bump version to 2.0devel due to significant changes and updated API (runtime config not fully backwards compatible).
* Reserve stack slot for luaL_error() during encodeMark Pulford2012-03-041-4/+11
| | | | | | | | | | 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.
* Remove deprecated "refuse_invalid_numbers"Mark Pulford2012-03-041-38/+0
| | | | | | Remove deprecated "refuse_invalid_numbers" since the version number will be bumped to 1.1.0. Also remove "version" variable since it has been replaced by _VERSION.
* Bump development version to 1.1develMark Pulford2012-03-041-1/+1
|
* Disable registration of cjson global variableMark Pulford2012-03-041-7/+2
| | | | | | | Disable registration of cjson module table global variable in the default build. Automatically creating a variable in the global namespace can cause issues for other software and is no longer recommended with Lua.
* Return boolean values from configuration functionsMark Pulford2012-03-041-5/+8
| | | | | | Return boolean values from configuration functions to simplify usage in the common case. Eg,: if not cjson.encode_invalid_numbers() then .. end
* Add depth/index to decode depth error messageMark Pulford2012-03-041-2/+3
| | | | | | | | | Include depth and character index when throwing decode nesting errors. Pre-emptively add a test decoding a massively nested JSON array. Lua stack overflow faults are unlikely to occur on simple data structures. Valgrind can highlight stack allocation bugs with complicated JSON even if the test succeeds.
* Fix Lua C function stack overflow during encodingMark Pulford2012-03-041-7/+12
| | | | | | | | | Ensure there are enough Lua stack slots available before descending into another table during encoding. This fixes a segfault when encoding deeply nested tables. This bug wasn't noticed earlier due to the previous limit of 20 nested tables.
* Simplify configuration function codeMark Pulford2012-03-041-60/+47
| | | | | | | Simplify configuration functions by adding an argument position parameter to json_enum_option() and json_integer_option(). Create json_arg_init() to check the number of arguments and return the config data.
* Merge lua_json_decode() into json_decode()Mark Pulford2012-03-041-28/+14
| | | | Also ensure cjson.decode() only receives a single argument.
* Update copyright date range to include 2012Mark Pulford2012-03-041-2/+2
|
* Change default nesting limits to 1000Mark Pulford2012-03-041-2/+2
| | | | | Increase the default nesting limits to reduce the chance of accidently throwing an error on valid JSON out of the box.
* Add option to encode invalid numbers as "null"Mark Pulford2012-03-041-65/+109
| | | | | Deprecate and replace refuse_invalid_numbers() with encode_invalid_numbers() and decode_invalid_numbers().
* Add configurable decode nesting limitMark Pulford2012-03-041-35/+63
| | | | | | | | | | | Lua 5.2 is able to extend the Lua stack much further than earlier versions. Recent testing shows it is possible for Lua CJSON to hit the process stack limit and segfault. Add a configurable JSON object/array nesting limit to prevent running out of process stack space. The current limit is 20 (same as encode). Add decode_max_depth() configuration function.
* Improve performance by tracking decode ptrMark Pulford2012-03-041-46/+49
| | | | | | | | | Track pointer to the current location in the JSON string, instead of an index to the string array. Improves decode performance 1-10%. json_next_token(): - Clean up white space handling and leave "ch" containing the current non-whitespace character.
* Fix typos (lists, hexadecimal)Mark Pulford2012-01-021-2/+2
|
* Add build option to disable invalid numbersMark Pulford2012-01-011-0/+15
| | | | | Windows MinGW doesn't convert Infinity/NaN/hexadecimal numbers. Add DISABLE_INVALID_NUMBERS build option option to disable invalid numbers.
* Sanitise locale code, comments and documentationMark Pulford2012-01-011-5/+2
|
* Minor code cleanupMark Pulford2011-12-311-10/+12
| | | | | | - Sanitised arg ordering to encode functions - Commented json->tmp to explain why decode string processing uses strbuf_*_unsafe() functions.
* Remove "update_locale" Lua functionMark Pulford2011-12-311-8/+0
| | | | | | | Only update the locale when the module is initialised. cjson.new() can be used if the locale changes part way through program execution.
* Add option for private bufferMark Pulford2011-12-311-26/+44
| | | | | | When encode_keep_buffer is false, a private buffer will be used. This will allow multiple encoders to run within a single Lua state.
* Remove shared current_depth var from cfg structMark Pulford2011-12-311-25/+17
|
* Add support for Lua 5.2 and cjson.newMark Pulford2011-12-301-16/+57
| | | | | | | | | | | | | | Update all Lua scripts to use new module init style everywhere: local json = require "cjson" Lua CJSON does not register a global table under Lua 5.2. The global table can be disabled under Lua 5.1 with DISABLE_CJSON_GLOBAL. Other changes: - Store CJSON configuration as an upvalue for each function. - Add "cjson.new" function to create another module table with a separate configuration. - Add _NAME and _VERSION variables.
* Add fpconv to work around comma decimal pointsMark Pulford2011-12-301-15/+21
| | | | | | | | Create a separate buffer and translate comma <> dot before calling strtod(), and after calling sprintf() as required. - Add "update_locale" Lua API call and init locale on module load. - Move sprintf format string to fpconv
* Remove POSIX locale workaroundMark Pulford2011-12-291-72/+0
|
* Fix typo in lua_cjson.cMark Pulford2011-12-241-1/+1
|
* Automate package releases with build-packages.shMark Pulford2011-12-151-1/+1
| | | | | | build-packages.sh has several advantages: - Automatically bumps version numbers - Builds HTML documentation on the fly
* Remove external VERSION #define for lua_cjson.cMark Pulford2011-12-131-1/+5
| | | | | The external #define complicates compilation but is only used in lua_cjson.c and Makefile.
* Add workaround to handle platforms that print -nanMark Pulford2011-11-291-6/+11
|
* Remove unused escape table init codeMark Pulford2011-11-291-26/+0
|
* Suppress isinf() define when it already existsMark Pulford2011-11-291-2/+2
|
* Add USE_POSIX_SETLOCALE optionMark Pulford2011-10-071-8/+30
| | | | | | | | | | Add USE_POSIX_SETLOCALE option for platforms missing uselocale(). Document locale options in README, Makefile & rockspec. Also: - Rename USE_POSIX_LOCALE define to USE_POSIX_USELOCALE. - Use uselocale() by default through Makefile (Linux, OSX). - Use setlocale() by default through rockspec (other platforms).
* Rename MISSING_ISINF to USE_INTERNAL_ISINFMark Pulford2011-10-071-2/+2
|
* Support locales which use comma decimal separatorsMark Pulford2011-10-051-0/+51
| | | | | | | | | | | | | Some locales (cs_CZ, de_DE,..) use a comma as their decimal separator. This causes CJSON to generate incorrect JSON (Eg, [10,1]), and fail when parsing some valid JSON (Eg, [10,"test"]). Added USE_POSIX_LOCALE #define which harnesses the thread-safe POSIX.1-2008 locale support (newlocale(), uselocale(), freelocale()) to temporarily use the POSIX locale during JSON conversion. Some older POSIX operating systems with xlocale.h (MacOSX) are also supported.
* Fix out of date comment (json_config_key)Mark Pulford2011-10-051-1/+1
|
* Update comment to match docs (very -> excessively)Mark Pulford2011-09-151-1/+1
|
* Add work around for missing isinf() on SolarisMark Pulford2011-08-111-0/+4
| | | | | | | Some versions of Solaris (Eg, Solaris 11 / GCC 3.4.3) are missing isinf(). Provide a work around when MISSING_ISINF is defined. Reported by: Zhang "agentzh" Yichun <agentzh@gmail.com>
* Fix detection of objects with numeric string keysMark Pulford2011-08-101-1/+1
| | | | | | | | | | | | lua_array_length() recognised some objects with numeric string keys as arrays since it was incorrectly using lua_isnumber(). When an object was incorrectly recognised as an array, json_append_array() would not find any entries and generate a result like: [null,null,...] Reported by: Zhang "agentzh" Yichun <agentzh@gmail.com>
* Add support for runtime number precision configMark Pulford2011-05-291-3/+40
| | | | | | Add cjson.encode_number_precision(). Reducing the number precision from 14 to 3 can increase performance up to 50% with number heavy conversions.
* Remove trailing whitespace1.0.1Mark Pulford2011-05-101-9/+9
|
* Add runtime option for persistent encode bufferMark Pulford2011-05-101-14/+47
|
* Fix memory leak when throwing stack overflow errorMark Pulford2011-05-101-2/+11
| | | | json->tmp was not freed when throwing a Lua stack overflow exception.
* Remove whitespace from generated JSON outputMark Pulford2011-05-101-8/+8
| | | | | | | Remove excess whitespace to reduce output size and increase encode performance. Suggested by: Zhang "agentzh" Yichun <agentzh@gmail.com>
* Tidy and reformat lua_cjson.c (minor)Mark Pulford2011-05-091-12/+9
|
* Generate error when attempting to decode UTF-16/32Mark Pulford2011-05-081-0/+8
|