aboutsummaryrefslogtreecommitdiff
path: root/manual.txt
diff options
context:
space:
mode:
Diffstat (limited to 'manual.txt')
-rw-r--r--manual.txt61
1 files changed, 47 insertions, 14 deletions
diff --git a/manual.txt b/manual.txt
index a3e12cf..810d3d1 100644
--- a/manual.txt
+++ b/manual.txt
@@ -16,8 +16,6 @@ Lua CJSON provides fast JSON parsing and encoding support for Lua.
16 16
17.Caveats 17.Caveats
18- UTF-16 and UTF-32 are not supported. 18- UTF-16 and UTF-32 are not supported.
19- Multi-threading within a single Lua state is not supported
20 (+lua_lock+ / +lua_unlock+).
21 19
22Lua CJSON is covered by the MIT license. Review the file +LICENSE+ for 20Lua CJSON is covered by the MIT license. Review the file +LICENSE+ for
23details. 21details.
@@ -32,7 +30,7 @@ comments.
32Installation Methods 30Installation Methods
33-------------------- 31--------------------
34 32
35Lua CJSON requires either http://www.lua.org[Lua] or 33Lua CJSON requires either http://www.lua.org[Lua] 5.1, Lua 5.2, or
36http://www.luajit.org[LuaJIT] to build. 34http://www.luajit.org[LuaJIT] to build.
37 35
38There are 4 build methods available: 36There are 4 build methods available:
@@ -44,11 +42,13 @@ RPM:: Linux
44LuaRocks:: Unix, Windows 42LuaRocks:: Unix, Windows
45 43
46 44
47Build options (#define) 45Build Options (#define)
48~~~~~~~~~~~~~~~~~~~~~~~ 46~~~~~~~~~~~~~~~~~~~~~~~
49 47
50[horizontal] 48[horizontal]
51USE_INTERNAL_ISINF:: Workaround for Solaris platforms missing isinf(). 49USE_INTERNAL_ISINF:: Workaround for Solaris platforms missing isinf().
50DISABLE_CJSON_GLOBAL:: Do not store module table in global "cjson"
51 variable.
52 52
53 53
54Make 54Make
@@ -125,9 +125,9 @@ Synopsis
125 125
126[source,lua] 126[source,lua]
127------------ 127------------
128require "cjson" 128-- Module initalisation methods
129-- Or:
130local cjson = require "cjson" 129local cjson = require "cjson"
130local cjson2 = cjson.new()
131 131
132-- Translate Lua value to/from JSON 132-- Translate Lua value to/from JSON
133text = cjson.encode(value) 133text = cjson.encode(value)
@@ -141,6 +141,34 @@ keep = cjson.encode_keep_buffer([keep])
141------------ 141------------
142 142
143 143
144Module Instantiation
145~~~~~~~~~~~~~~~~~~~~
146
147[source,lua]
148------------
149local cjson = require "cjson"
150local cjson2 = cjson.new()
151------------
152
153Lua CJSON can be loaded via +require+. A global +cjson+ table is
154registered under Lua 5.1 to maintain backward compatibility. Lua CJSON
155does not register a global table under Lua 5.2 since this practice is
156discouraged.
157
158+cjson.new+ can be used to instantiate an independent copy of the Lua
159CJSON module. The new module has a separate persistent encoding
160buffer, and default settings.
161
162Lua CJSON can support Lua implementations using multiple pre-emptive
163threads within a single Lua state provided the persistent encoding
164buffer is not shared. This can be achieved by one of the following
165methods:
166
167- Disabling the persistent encoding buffer with +encode_keep_buffer+.
168- Ensuring only a single thread calls +encode+ at a time.
169- Using a separate +cjson+ instantiation per pre-emptive thread.
170
171
144decode 172decode
145~~~~~~ 173~~~~~~
146 174
@@ -423,6 +451,18 @@ Disabled for decoding:: All numbers supported by +strtod+(3) will be parsed.
423API (Variables) 451API (Variables)
424--------------- 452---------------
425 453
454_NAME
455~~~~~
456
457The name of the Lua CJSON module (+"cjson"+).
458
459
460_VERSION
461~~~~~~~~
462
463The version number of the Lua CJSON module (Eg, +"1.0devel"+).
464
465
426null 466null
427~~~~ 467~~~~
428 468
@@ -430,13 +470,6 @@ Lua CJSON decodes JSON +null+ as a Lua +lightuserdata+ NULL pointer.
430+cjson.null+ is provided for comparison. 470+cjson.null+ is provided for comparison.
431 471
432 472
433version
434~~~~~~~
435
436The version number of the Lua CJSON module in use can be found in
437+cjson.version+.
438
439
440[sect1] 473[sect1]
441References 474References
442---------- 475----------
@@ -445,4 +478,4 @@ References
445- http://www.json.org/[JSON website] 478- http://www.json.org/[JSON website]
446 479
447 480
448// vi:tw=70: 481// vi:ft=asciidoc tw=70: