| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
cjson.encode_number_precision().
thanks lordnynex for the patch in #4.
Test cases for changing precision
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Deprecate and replace refuse_invalid_numbers() with
encode_invalid_numbers() and decode_invalid_numbers().
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
Only update the locale when the module is initialised.
cjson.new() can be used if the locale changes part way
through program execution.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
|
|
|
|
| |
Display failed tests, and successful/total test counts.
Use "awk" to provide a portable "ggrep -E" with context.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
| |
|
|
|
|
|
|
|
| |
Sprintf returns "-nan" rather than "nan" on some platforms, which causes
the test script to incorrectly flag a failure.
Also allow test functions without "==> Config" output.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Remove excess whitespace to reduce output size and increase encode
performance.
Suggested by: Zhang "agentzh" Yichun <agentzh@gmail.com>
|
|
|
|
|
|
| |
- Use pcall() to call test config functions.
- Test encoding with refuse_invalid_numbers() options.
- Test encoding invalid types.
|
| |
|