aboutsummaryrefslogtreecommitdiff
path: root/lua/lua2json.lua (unfollow)
Commit message (Collapse)AuthorFilesLines
2012-03-04Reserve stack slot for luaL_error() during encodeMark Pulford1-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.
2012-03-04Add an RPM %preun script to remove utf8.datMark Pulford1-0/+4
Add an RPM %preun script to remove utf8.dat. Otherwise the user generated test file will cause RPM to leave behind the cjson/tests module directories.
2012-03-04Remove deprecated "refuse_invalid_numbers"Mark Pulford2-40/+2
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.
2012-03-04Bump development version to 1.1develMark Pulford7-13/+13
2012-03-04Disable registration of cjson global variableMark Pulford5-14/+9
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.
2012-03-04Return boolean values from configuration functionsMark Pulford2-16/+19
Return boolean values from configuration functions to simplify usage in the common case. Eg,: if not cjson.encode_invalid_numbers() then .. end
2012-03-04Add CMake option to toggle DISABLE_CJSON_GLOBALMark Pulford1-0/+5
2012-03-04Add depth/index to decode depth error messageMark Pulford2-4/+8
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.
2012-03-04Fix Lua C function stack overflow during encodingMark Pulford2-7/+21
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.
2012-03-04Update archive download URLMark Pulford2-2/+2
2012-03-04Recommend genutf8.pl when utf8.dat is missingMark Pulford1-1/+1
2012-03-04Add "throw error" to test descriptionsMark Pulford1-41/+41
Add "throw error" to descriptions for tests which are intended to generate errors.
2012-03-04Test config API errors and setting configurationMark Pulford1-28/+66
- Update comments - Use enumerated return values - Test various configuration API errors - Test resetting configuration to default
2012-03-04Tidy tests and improve coverageMark Pulford2-85/+113
- Rearrange test sections to keep more related tests together. - Test configuration functions for errors Add tests for more parts of the Lua CJSON API: - _NAME, _VERSION, version - encode_keep_buffer - encode_number_precision - decode_invalid_numbers - decode_max_depth
2012-03-04Place nested data structure inline with testsMark Pulford1-4/+2
Make the tests more explicit, the nested data structure doesn't need to be generated in advance.
2012-03-04Gather all test data into a tableMark Pulford1-20/+32
Move all test data into a single data to tidy the main namespace.
2012-03-04Add descriptions to all testsMark Pulford2-160/+204
Rewrite test framework and add descriptions for all tests.
2012-03-04Simplify configuration function codeMark Pulford1-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.
2012-03-04Merge lua_json_decode() into json_decode()Mark Pulford1-28/+14
Also ensure cjson.decode() only receives a single argument.
2012-03-04Add tests for decode_max_depth()Mark Pulford1-5/+13
2012-03-04Use Lua CJSON instead of CJSON in documentationMark Pulford1-3/+3
2012-03-04Update copyright date range to include 2012Mark Pulford5-6/+30
2012-03-04Change default nesting limits to 1000Mark Pulford2-5/+5
Increase the default nesting limits to reduce the chance of accidently throwing an error on valid JSON out of the box.
2012-03-04Improve benchmark stabilityMark Pulford1-7/+36
Update benchmark script to average the best half (round up) of the result set. Ensure the initial call rate is calculated from a run of at least 1ms. Remove garbage collection control since any variations due to garbage collection are better handled by averaging multiple results.
2012-03-04Use static strtod() buffer where possibleMark Pulford1-5/+13
Use static strtod() buffer where possible to improve performance 5-10% under locales with a comma decimal point.
2012-03-04Add option to encode invalid numbers as "null"Mark Pulford3-111/+180
Deprecate and replace refuse_invalid_numbers() with encode_invalid_numbers() and decode_invalid_numbers().
2012-03-04Add configurable decode nesting limitMark Pulford2-35/+89
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.
2012-03-04Update rockspec to install lua2json/json2luaMark Pulford1-0/+9
2012-03-04Update RPM to install extra scripts via makeMark Pulford1-2/+8
2012-03-04Add make target for cjson.util and scriptsMark Pulford1-5/+27
Add install-extra make target to install cjson.util module, extra scripts and tests. Use "cp" / "chmod" instead of "install" since they are more portable.
2012-03-04Rename "cjson-misc" module to "cjson.util"Mark Pulford5-24/+24
2012-03-04Move cjson-misc and scripts to "lua" directoryMark Pulford3-0/+0
2012-03-04Use DISABLE_INVALID_NUMBERS on WIN32 CMake buildsMark Pulford1-7/+7
2012-03-04Fix typo in manualMark Pulford1-2/+2
2012-03-04Update cjson-misc.lua file descriptionMark Pulford1-1/+1
2012-03-04Improve performance by tracking decode ptrMark Pulford1-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.
2012-03-04Update bench.lua to support different JSON modulesMark Pulford3-41/+62
- Select via JSON_MODULE environment variable (default "cjson") - Custom runtime configuration can be stored in bench-MODNAME.lua - Add run_script() to cjson-misc and update lua2cjson.lua
2012-03-04Add support to USE_INTERNAL_DTOA to CMake buildMark Pulford1-7/+41
- Provide build options for USE_INTERNAL_DTOA and MULTIPLE_THREADS - Link module with Lua library under Windows
2012-03-04Limit significant digits in numbers.json to 14Mark Pulford1-6/+6
The dtoa.c strtod() function slows down significantly when the number of digits exceeds the accuracy of a "double". JSON containing excessive digits is an unrepresentative test, limit to 14 digits.
2012-03-04Add error checking to dtoa locking primitivesMark Pulford1-4/+12
2012-03-04Document dtoa build optionsMark Pulford1-0/+16
2012-03-04Use internal dtoa/strtod for double conversionMark Pulford6-16/+123
The internal Lua CJSON dtoa/strtod routines have locale support disabled. This avoids problems under locales with comma decimal separators. Build changes: - CMake: Check for big endian architectures - Makefile: Provide option to build with dtoa.c Modifications to dtoa.c: - Include locale dtoa_config.h configuration - Rename Infinity/NaN to inf/nan to match common C libraries - Rename strtod() -> internal_strtod() to prevent conflict with libc function Modifications to g_fmt.c: - Return output string length (instead of original buffer pointer) - Provide precision as an argument to g_fmt() - Silence compilations warnings from vendor source - while(a = b) - Unused label "done:" - Only swap to scientific notation when once the number of decimal digits required exceeds the precision available. This matches standard printf format %g. - Display a "0" in front of numbers < 1.
2012-01-03Add support for Lua 5.2 environments to lua2jsonMark Pulford1-9/+23
2012-01-03Rename encode/decode scripts to lua2json/json2luaMark Pulford2-6/+6
2012-01-03Convert common.lua into cjson-misc moduleMark Pulford5-35/+43
2012-01-02Tidy Makefile sections and commentsMark Pulford1-17/+16
2012-01-02Fix Windows TARGET modificationsMark Pulford1-3/+3
2012-01-02Fix typos (lists, hexadecimal)Mark Pulford2-9/+9
2012-01-02Update all package descriptions for consistencyMark Pulford3-9/+19
2012-01-01Add build option to disable invalid numbersMark Pulford4-16/+39
Windows MinGW doesn't convert Infinity/NaN/hexadecimal numbers. Add DISABLE_INVALID_NUMBERS build option option to disable invalid numbers.