| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| | |
Move benchmark() into bench.lua since it not used elsewhere.
Replace posix.gettimeofday() with socket.gettime() to improve portability.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
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 "-lm" from LDFLAGS in Makefile since it breaks the build under
Windows and isn't required under Linux. Math lib fix suggested by:
Steve Donovan <steve.j.donovan@gmail.com>
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
Suspending GC appears to make the benchmark results more consistent.
|
| |
| |
| |
| | |
json->tmp was not freed when throwing a Lua stack overflow exception.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
Change "perl -w" to "use warnings" for compatibility with systems that
put all #! args into argv[1].
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
- 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
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
- Add run_test(): Test a function and verify its output
- Add run_test_group(): Execute a test batch
- Add serialise_value(): Serialise a Lua value into the Lua syntax
- Add file_save() helper function
- Add NaN comparison support to compare_values()
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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.
|
| | |
|
| |
| |
| |
| |
| | |
Escaping forward slash can be useful when including JSON output
in HTML (Eg, embedded in SCRIPT tags).
|
| |
| |
| |
| | |
- Add __gc metatable method to clean up json_config_t userdata.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Douglas Crockford <douglas@crockford.com> has given permission
for these examples to be used.
Message-ID: <4DC01FB7.8090001@crockford.com>
Date: Tue, 03 May 2011 08:31:03 -0700
From: Douglas Crockford
To: Mark Pulford
Subject: Re: JSON examples
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
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 length and hide the string
implementation.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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..
|
| |
| |
| |
| |
| |
| |
| |
| | |
The separate strbuf_append_number() function avoids a potential double
call to the slow vsnprintf() function required by strbuf_append_fmt().
Also inline strbuf_append_mem() since it is very simple and will
be used often.
|
| |
| |
| |
| |
| | |
- Add Makefile and RPM spec file
- Add cjson.version variable
|
| |
| |
| |
| |
| | |
- Fix typo and comment
- Change "while" to "for" loop
|
| |
| |
| |
| |
| | |
Change strict_numbers to control whether json.decode will parse an
expanded set of numbers (Hex, Inf, NaN).
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
Add runtime configuration for generating Inf/NaN encoding errors through
cjson.strict_numbers().
|
| |
| |
| |
| |
| | |
Was: Cannot serialise <location>: <type>
Now: Cannot serialise <type>: <reason>
|
| |
| |
| |
| |
| |
| |
| | |
- 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.
|