aboutsummaryrefslogtreecommitdiff
path: root/lua_cjson.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
|
* Add UTF-16 surrogate pair decode supportMark Pulford2011-05-081-9/+56
| | | | | | | | - Add tests for UTF-16 decoding and failures - Add getutf8.pl to assist with UTF-16 decode testing - Re-add test_decode_cycle() which was accidentally removed earlier - Rename bytestring.dat to octets-escaped.dat
* Rework runtime config optionsMark Pulford2011-05-071-56/+118
| | | | | | | | | | | | | | | | | | | | | - Rename API for consistency: - sparse_ratio() -> encode_sparse_array() - max_depth() -> encode_max_depth() - invalid_numbers() -> refuse_invalid_numbers() - Adjust sparse array handling: - Add "safe" option to allow small sparse arrays regardless of the ratio. - Generate an error by default instead of converting an array into an object (POLA). - Update invalid number handling: - Allow decoding invalid numbers by default since many JSON implementations output NaN/Infinity. - Throw an error by default when attempting to encode NaN/Infinity since the RFC explicitly states it is not permitted. - Support specifying invalid number configuration separately for encode/decode.
* Escape forward slash when encodingMark Pulford2011-05-071-1/+1
| | | | | Escaping forward slash can be useful when including JSON output in HTML (Eg, embedded in SCRIPT tags).
* Fix strbuf_t leak on lua_close()Mark Pulford2011-05-051-3/+20
| | | | - Add __gc metatable method to clean up json_config_t userdata.
* Generate parse error for invalid leading zerosMark Pulford2011-05-031-8/+17
|
* Preallocate temporary decode string bufferMark Pulford2011-05-031-11/+14
| | | | | The preallocated buffer removes the need for buffer length checks while processing strings and results in a 10 - 15% speedup.
* Add strbuf_reset() to reset string lengthMark Pulford2011-05-031-2/+2
| | | | | Add strbuf_reset() to reset string length and hide the string implementation.
* Escape all unprintable ASCII when encodingMark Pulford2011-05-031-47/+94
| | | | | | | | | | | | Replace json_escape_char() with a static char2escape[] lookup table. Escape all unprintable ASCII (0-31, 127) and JSON special characters (double quote, backslash). Dynamic creation of the char2escape table has been left commented out due to an apparent performance hit. The performance loss may be due to memory/page alignment (unknown). Rename parsing lookup table from ch2escape to escape2char for consistency.
* Implement minor performance improvementsMark Pulford2011-05-031-42/+50
| | | | | | | | | | | | | | | - Use strbuf_append_mem() for small static strings (~2% speedup). - Use &json_config_key for storing registry data. It's more unique and faster than a text string. - Use strbuf_append_char_unsafe() for string quotes (~4% speedup). - Use strbuf_append_number() instead of strbuf_append_fmt(). It is much simpler and avoids the potential for 2 expensive calls to vsnprintf(). - Make encoding buffer persistent across calls to avoid extra malloc/free (~4% speedup on example2.json). These performance improvements can be much more pronounced depending on the data. Eg, small strings, numbers, booleans, etc..
* Add build and package supportMark Pulford2011-05-011-0/+4
| | | | | - Add Makefile and RPM spec file - Add cjson.version variable
* Update lua_cjson.c with minor fixesMark Pulford2011-05-011-6/+3
| | | | | - Fix typo and comment - Change "while" to "for" loop
* Support optionally parsing Inf/NaN/Hex numbersMark Pulford2011-05-011-31/+73
| | | | | Change strict_numbers to control whether json.decode will parse an expanded set of numbers (Hex, Inf, NaN).
* Add MIT license and update lua_cjson.c caveatsMark Pulford2011-05-011-18/+34
|
* Detect and throw error when parsing hexadecimalMark Pulford2011-05-011-10/+20
|
* Simplify generating parse error tokensMark Pulford2011-05-011-28/+29
|
* Throw error on Inf/NaN by default when encodingMark Pulford2011-05-011-16/+49
| | | | | Add runtime configuration for generating Inf/NaN encoding errors through cjson.strict_numbers().
* Improve encoding exception error formatMark Pulford2011-05-011-6/+7
| | | | | Was: Cannot serialise <location>: <type> Now: Cannot serialise <type>: <reason>
* Add detailed parse error reportingMark Pulford2011-05-011-19/+45
| | | | | | | - Always report the correct index of the token error. - Use value.string to report what was found instead of just T_ERROR. - Fix inverted unicode escape error detection.
* Move static configuration into runtime userdataMark Pulford2011-05-011-137/+230
| | | | | | | Allow maximum nesting depth and sparse array ratio to be configured at runtime via the sparse_ratio() and max_depth() functions. Throw exceptions when encoding excessively nested structures.
* Encode very sparse arrays as objectsMark Pulford2011-05-011-1/+14
| | | | | | | Detect and encode very sparse arrays as objects. This prevents something like: { [1000000] = "nullfest" } ..from generating a huge array.
* Create "cjson" Lua module, support UCS-2 escapesMark Pulford2011-05-011-0/+780
- Convert lua_json_init() into luaopen_cjson() to support dynamic .so loading. - Rename "json" to "cjson" to reduce conflicts with other JSON modules. - Remove unnecessary *_pcall_* API. Lua calls are fast enough, even through C. - Encode empty tables as objects - Add support for decoding all UCS-2 escape codes.