| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
Co-Authored-By: Hisham Muhammad <hisham@gobolinux.org>
Co-authored-by: Mark Pulford <mark@kyne.com.au>
Co-authored-by: ichenq <ichenq@gmail.com>
Co-authored-by: Cloud Wu <cloudwu@gmail.com>
Co-authored-by: caijietao <t0350.prog@gmail.com>
Co-authored-by: actboy168 <actboy168@gmail.com>
Co-authored-by: wudeng <wudeng256@gmail.com>
Co-authored-by: caiyiheng <rangercyh@qq.com>
|
|
|
| |
Co-authored-by: Jesper Lundgren <jesperlundgren@exosite.com>
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Thanks @spacewander for optimization and documentation.
|
| |
|
|
|
|
|
|
|
| |
this can be turned on via cjson.decode_array_with_array_mt(true). off by
default.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
|
|
|
|
|
|
| |
encoding.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this fix, when the module would be loaded several times
(by-passing `package.loaded`), the `lua_cjson_new` function would
override the `empty_array_mt` table in the registry with a new one.
Comparison for equality between those tables would then fail, and the
behavior would be broken.
This was discovered after loading `cjson` *and* `cjson.safe` in the same
application, resulting in two calls to `lua_cjson_new`.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A proposed improved patch of openresty/lua-cjson#1 (a patch commonly
proposed to lua-cjson and its forks), taking into considerations
comments from the original PR.
- use a lightuserdata key to store the metatable in the Lua Registry
(more efficient and avoiding conflicts)
- provide a lightuserdata resulting in empty arrays as well
- tests cases moved to t/agentzh.t, where cases for
'encode_empty_table_as_object' are already written. It seems like a
better place for tests specific to the OpenResty fork's additions.
- a more complex test case
|
|
|
|
|
|
|
|
| |
cjson.encode_number_precision().
thanks lordnynex for the patch in #4.
Test cases for changing precision
|
| |
|
| |
|
|
|
|
| |
encode_empty_table_as_object so that we can encode empty Lua tables into empty JSON arrays.
|
|
|
|
|
| |
Use Javascript compatible values for Infinity/NaN when encoding invalid
numbers.
|
| |
|
|
|
|
| |
Add cjson.safe module to suppress exceptions during JSON conversions.
|
|
|
|
|
| |
Bump version to 2.0devel due to significant changes and updated API
(runtime config not fully backwards compatible).
|
|
|
|
| |
Simply string.format() calls with OO method notation.
|
|
|
|
|
|
| |
Create separate tests for numbers with leading zeros. This allows the
earlier "normal" number test to pass. Also update hexadecimal test to use
the "p" exponent format.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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 functions to simplify usage in
the common case. Eg,:
if not cjson.encode_invalid_numbers() then .. end
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Add "throw error" to descriptions for tests which are intended to
generate errors.
|
|
|
|
|
|
|
| |
- Update comments
- Use enumerated return values
- Test various configuration API errors
- Test resetting configuration to default
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
| |
Make the tests more explicit, the nested data structure doesn't need to
be generated in advance.
|
|
|
|
| |
Move all test data into a single data to tidy the main namespace.
|
|
|
|
| |
Rewrite test framework and add descriptions for all tests.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Deprecate and replace refuse_invalid_numbers() with
encode_invalid_numbers() and decode_invalid_numbers().
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|