diff options
Diffstat (limited to 'manual.txt')
-rw-r--r-- | manual.txt | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -48,7 +48,7 @@ Build Options (#define) | |||
48 | [horizontal] | 48 | [horizontal] |
49 | USE_INTERNAL_ISINF:: Workaround for Solaris platforms missing isinf(). | 49 | USE_INTERNAL_ISINF:: Workaround for Solaris platforms missing isinf(). |
50 | DISABLE_CJSON_GLOBAL:: Do not store module table in global "cjson" | 50 | DISABLE_CJSON_GLOBAL:: Do not store module table in global "cjson" |
51 | variable. | 51 | variable. Redundant from Lua 5.2 onwards. |
52 | 52 | ||
53 | 53 | ||
54 | Make | 54 | Make |
@@ -150,10 +150,10 @@ local cjson = require "cjson" | |||
150 | local cjson2 = cjson.new() | 150 | local cjson2 = cjson.new() |
151 | ------------ | 151 | ------------ |
152 | 152 | ||
153 | Lua CJSON can be loaded via +require+. A global +cjson+ table is | 153 | Lua CJSON can be loaded via the Lua +require+ function. A global |
154 | registered under Lua 5.1 to maintain backward compatibility. Lua CJSON | 154 | +cjson+ module table is registered under Lua 5.1 to maintain backward |
155 | does not register a global table under Lua 5.2 since this practice is | 155 | compatibility. Lua CJSON does not register a global table under Lua |
156 | discouraged. | 156 | 5.2 since this practice is discouraged. |
157 | 157 | ||
158 | +cjson.new+ can be used to instantiate an independent copy of the Lua | 158 | +cjson.new+ can be used to instantiate an independent copy of the Lua |
159 | CJSON module. The new module has a separate persistent encoding | 159 | CJSON module. The new module has a separate persistent encoding |
@@ -164,9 +164,21 @@ threads within a single Lua state provided the persistent encoding | |||
164 | buffer is not shared. This can be achieved by one of the following | 164 | buffer is not shared. This can be achieved by one of the following |
165 | methods: | 165 | methods: |
166 | 166 | ||
167 | - Disabling the persistent encoding buffer with +encode_keep_buffer+. | 167 | - Disabling the persistent encoding buffer with |
168 | - Ensuring only a single thread calls +encode+ at a time. | 168 | +cjson.encode_keep_buffer+. |
169 | - Using a separate +cjson+ instantiation per pre-emptive thread. | 169 | - Ensuring each thread calls +cjson.encode+ at a time. |
170 | - Using a separate +cjson+ module table per pre-emptive thread | ||
171 | (+cjson.new+). | ||
172 | |||
173 | [NOTE] | ||
174 | Lua CJSON uses ++strtod++(3) and ++snprintf++(3) to perform numeric | ||
175 | conversion as they are usually well supported, fast and bug free. | ||
176 | However, these functions require a workaround for JSON | ||
177 | encoding/parsing under locales using a comma decimal separator. Lua | ||
178 | CJSON detects the current locale during instantiation to determine | ||
179 | whether a workaround is required. CJSON should be reinitialised via | ||
180 | +cjson.new+ if the locale of the current process changes. Different | ||
181 | locales per thread are not supported. | ||
170 | 182 | ||
171 | 183 | ||
172 | decode | 184 | decode |