LuaJSON(3)
==========
:Author: Thomas Harning
:Email: harningt@[Link]
:Date: 2009/04/29
NAME
----
luajson - JSON encoder/decoder for Lua
SYNOPSIS
--------
require("json")
[Link]("json-string" [, parameters])
[Link](parameters)
[Link](lua_value [, parameters])
[Link](parameters)
DESCRIPTION
-----------
[Link]("json-string" [, parameters])::
Obtains a JSON decoder using `getDecoder` with the parameters specified,
then performs the decoding operation.
[Link](lua_value [, parameters])::
Obtains a JSON encoder using `getEncoder` with the parameters specified,
then performs the encoding operation.
[Link](parameters)::
Obtains a JSON decoder configured with the given parameters or defaults.
[Link](parameters)::
Obtains a JSON encoder configured with the given parameters or defaults.
[Link]::
A default parameter specification containing 'strict' rules for encoding
[Link]::
A default parameter specification containing 'strict' rules for decoding
=== COMMON PARAMETERS
initialObject : boolean::
Specifies if the outermost element be an array or object
allowUndefined : boolean::
Specifies if 'undefined' is an allowed value
null : any::
Placeholder object for null values
undefined : any::
Placeholder for undefined values
[Link] : boolean::
Specifies if NaN is an allowed value
[Link] : boolean::
Specifies if +/-Infinity is an allowed value
=== ENCODER-SPECIFIC PARAMETERS
preProcess : `function(object)`::
Called for every value to be encoded, optionally altering.
If returns `nil` then no value change occurs.
output : function::
Function that returns an encoder specification (TBD), if null
default used that returns a string.
[Link] : `function(object)`::
If `true`/`false` returned, then the value is authoritatively
an array or not
[Link] : boolean::
Specifies if binary values are to be encoded with \xNN rather than \uNNNN
[Link] : string::
[Link] set of
characters that need to be escaped (to be contained in `[]`)
[Link] : string::
Set of characters that need to be escaped (to be contained in `[]`).
Appended to the current encodeSet.
==== Default Configuration
[source,lua]
----
[Link] == json-util's isArray implementation
allowUndefined = true
[Link] = true
[Link] = true
[Link] = false
[Link] = '\\"/%z\1-\031'
----
==== Strict Configuration
[source,lua]
----
initialObject = true
allowUndefined = false
[Link] = false
[Link] = false
----
=== DECODER-SPECIFIC PARAMETERS
unicodeWhitespace : boolean::
Specifies if unicode whitespace characters are counted
[Link] / [Link] : boolean::
Specifies if extraneous trailing commas are ignored in declaration
[Link] : map<string | LPEG, function | boolean>::
Defines set of specifically permitted function definitions.
If boolean value, determines if allowed or not, decoded as a call object.
Function return-value is the decoded result.
Function definition: `function(name, [arguments])` : output-value
[Link] : boolean::
Specifies if undefined call definitions are decoded as call objects.
[Link] : boolean::
Specifies if numbers can have a decimal component (ex: `.01`)
[Link] : boolean::
Specifies if exponents are allowed (ex: `1e2`)
[Link] : boolean::
Specifies if hexadecimal numbers are allowed (ex: `0xDEADBEEF`)
[Link] : boolean::
Specifies if numbers can be object keys
[Link] : boolean::
Specifies if unquoted 'identifiers' can be object keys (matching `[A-Za-z_][A-
Za-z0-9_]*`)
[Link] : string::
Set of characters that should not be present in a string
[Link] : LPeg expression::
LPeg expression to handle output (ex: `lpeg.C(1)` would take `\k` and spit out
`k`)
[Link] : non-consuming LPeg expression::
LPeg expression to check if a given character is allowed to be an escape value
[Link]::
`function (XX, YY)` handling \uXXYY situation to output decoded unicode
sequence
strings.strict_quotes : boolean::
Specifies if the `'` character is considered a quoting specifier
==== Default configuration
[source,lua]
----
unicodeWhitespace = true
initialObject = false
allowUndefined = true
[Link] = true
[Link] = true
[Link] = true
[Link] = false
[Link] = true
[Link] = true
[Link] = true
[Link] = '' -- No characters considered bad in a string
[Link] = false, -- disallow untranslated escapes
[Link] = #lpeg.S('bfnrtv/\\"xu\'z'),
[Link] = utf8DecodeUnicode,
strings.strict_quotes = false
----
==== Strict configuration
[source,lua]
----
initialObject = true
allowUndefined = false
[Link] = false
[Link] = false
[Link] = false
[Link] = '\b\f\n\r\t\v'
[Link] = false -- no additional escapes
[Link] = #lpeg.S('bfnrtv/\\"u') --only these are allowed to be escaped
strings.strict_quotes = true
----
AUTHOR
------
Written by Thomas Harning Jr., <harningt@[Link]>
REFERENCES
----------
[Link]
[Link]
COPYING
-------
Copyright (C) 2008-2009 Thomas Harning Jr. Free use of this software is granted
under the terms of the MIT license.