aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-12-20 00:14:16 +1030
committerMark Pulford <mark@kyne.com.au>2011-12-20 00:14:16 +1030
commitfe25699a3ba84a35fac58bc7236ab6b3ff3e7ba3 (patch)
treea1ab65bc27651e6b7004e4e42494101ec7b881d1
parent7bbb4bd8decb8239c78abe3c7f54dafb9fca8120 (diff)
downloadlua-cjson-fe25699a3ba84a35fac58bc7236ab6b3ff3e7ba3.tar.gz
lua-cjson-fe25699a3ba84a35fac58bc7236ab6b3ff3e7ba3.tar.bz2
lua-cjson-fe25699a3ba84a35fac58bc7236ab6b3ff3e7ba3.zip
Add UTF-8 caution to manual (and misc changes)
-rw-r--r--manual.txt34
1 files changed, 24 insertions, 10 deletions
diff --git a/manual.txt b/manual.txt
index bb946fe..8a894c0 100644
--- a/manual.txt
+++ b/manual.txt
@@ -1,6 +1,6 @@
1= Lua CJSON 1.0devel Manual = 1= Lua CJSON 1.0devel Manual =
2Mark Pulford <mark@kyne.com.au> 2Mark Pulford <mark@kyne.com.au>
3:revdate: 30th November 2011 3:revdate: November 30, 2011
4 4
5Overview 5Overview
6-------- 6--------
@@ -8,7 +8,7 @@ Overview
8Lua CJSON provides fast JSON parsing and encoding support for Lua. 8Lua CJSON provides fast JSON parsing and encoding support for Lua.
9 9
10.Features 10.Features
11- More than 10x to 20x faster than the efficient pure Lua JSON modules. 11- More than 10x to 20x faster than efficient pure Lua JSON modules.
12- Full support for JSON with UTF-8, including decoding surrogate 12- Full support for JSON with UTF-8, including decoding surrogate
13 pairs. 13 pairs.
14- Optional run-time support for common exceptions to the JSON 14- Optional run-time support for common exceptions to the JSON
@@ -48,10 +48,9 @@ Build options (#define)
48~~~~~~~~~~~~~~~~~~~~~~~ 48~~~~~~~~~~~~~~~~~~~~~~~
49 49
50Lua CJSON uses +strtod+(3) and +snprintf+(3) to perform numeric 50Lua CJSON uses +strtod+(3) and +snprintf+(3) to perform numeric
51conversion as they are usually well supported, fast and bug free. To 51conversion as they are usually well supported, fast and bug free. Lua
52ensure JSON encoding/decoding works correctly under locales using 52CJSON may optionally be compiled with (only) one of the following
53comma decimal separators, Lua CJSON may optionally be compiled with 53preprocessor macros to support locales with comma decimal separators:
54one of the following preprocessor macros:
55 54
56[horizontal] 55[horizontal]
57USE_POSIX_USELOCALE:: Thread safe. Supported by Linux and Mac OSX. 56USE_POSIX_USELOCALE:: Thread safe. Supported by Linux and Mac OSX.
@@ -222,9 +221,10 @@ The remaining Lua types will generate an error:
222- +userdata+ 221- +userdata+
223 222
224By default, numbers are encoded using the standard Lua number 223By default, numbers are encoded using the standard Lua number
225+printf+(3) format ("%.14g"). 224+printf+(3) format (+%.14g+).
226 225
227Lua CJSON will escape the following characters within each string: 226Lua CJSON will escape the following characters within each UTF-8
227string:
228 228
229- Control characters (ASCII 0 - 31) 229- Control characters (ASCII 0 - 31)
230- Double quote (ASCII 34) 230- Double quote (ASCII 34)
@@ -232,8 +232,20 @@ Lua CJSON will escape the following characters within each string:
232- Blackslash (ASCII 92) 232- Blackslash (ASCII 92)
233- Delete (ASCII 127) 233- Delete (ASCII 127)
234 234
235All other characters are passed transparently. Any UTF-8 error 235All other characters are passed transparently.
236checking must be done by the application. 236
237[CAUTION]
238=========
239Lua CJSON will successfully encode/decode binary strings, but this is
240technically not supported by JSON and may not be compatible with other
241JSON libraries. Applications should ensure all Lua strings passed to
242+cjson.encode+ are valid UTF-8 to ensure the output is valid JSON.
243
244Base64 is a common way to transport binary data through JSON. Lua
245Base64 routines can be found in the
246http://w3.impa.br/~diego/software/luasocket/[LuaSocket] and
247http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbase64[lbase64] packages.
248=========
237 249
238Lua CJSON uses a heuristic to determine whether to encode a Lua table 250Lua CJSON uses a heuristic to determine whether to encode a Lua table
239as a JSON array or an object. A Lua table with only positive integers 251as a JSON array or an object. A Lua table with only positive integers
@@ -256,6 +268,7 @@ generate an error.
256Standards compliant JSON must be encapsulated in either an object 268Standards compliant JSON must be encapsulated in either an object
257(+{}+) or an array (+[]+). Hence a table must be passed to 269(+{}+) or an array (+[]+). Hence a table must be passed to
258+cjson.encode+ to generate standards compliant JSON output. 270+cjson.encode+ to generate standards compliant JSON output.
271This may not be required by some applications.
259 272
260By default, the following Lua values will generate errors: 273By default, the following Lua values will generate errors:
261 274
@@ -430,4 +443,5 @@ References
430- http://tools.ietf.org/html/rfc4627[RFC 4627] 443- http://tools.ietf.org/html/rfc4627[RFC 4627]
431- http://www.json.org/[JSON website] 444- http://www.json.org/[JSON website]
432 445
446
433// vi:tw=70: 447// vi:tw=70: