descriptionJSON Parser/Constructor for Lua Uses LPeg to decode JSON and tables to encode JSON See canonical GitHub repository: https://www.github.com/harningt/luajson. See http://www.ohloh.net/projects/11513
homepage URLhttps://github.com/harningt/luajson
repository URLgit://github.com/harningt/luajson.git
ownerharningt@gmail.com
last changeWed, 1 Feb 2017 05:00:25 +0000 (1 00:00 -0500)
last refreshMon, 10 Dec 2018 04:08:28 +0000 (10 05:08 +0100)
content tags
add:
README.md

LuaJSON

JSON Parser/Constructor for Lua

Author:

Thomas Harning Jr. <harningt@gmail.com>

Source code:

http://repo.or.cz/luajson

Bug reports:

http://github.com/harningt/luajson harningt@gmail.com

Requirements

Lua 5.1, 5.2, 5.3, LuaJIT 2.0, or LuaJIT 2.1 LPeg (Tested with 0.7, 0.8, 0.9, 0.10, 0.12rc2, 1.0.1) For regressionTest: lfs (Tested with 1.6.3)

For lunit-tests:

lunitx >= 0.8

NOTE:

LPeg 0.11 may not work - it crashed during my initial tests, it is not in the test matrix.

Lua versions tested recently:

License

All-but tests: MIT-style, See LICENSE for details tests/*: Public Domain / MIT - whichever is least restrictive

Module/Function overview:

json.encode (callable module referencing json.encode.encode)

encode ( value : ANY-valid )

Takes in a JSON-encodable value and returns the JSON-encoded text Valid input types:

Table keys (string,number,boolean) are encoded as strings, others are erroneus Table values are any valid input-type Array-like tables are converted into JSON arrays... Position 1 maps to JSON Array position 0

json.decode (callable module referencing json.decode.decode)

decode (data : string, strict : optional boolean)

Takes in a string of JSON data and converts it into a Lua object If 'strict' is set, then the strict JSON rule-set is used

json.util

Useful utilities

null

Reference value to represent 'null' in a well-defined way to allow for null values to be inserted into an array/table

undefined

Reference value to represent 'undefined' in a well-defined way to allow for undefined values to be inserted into an array/table.

IsArray (t : ANY)

Checks if the passed in object is a plain-old-array based on whether or not is has the LuaJSON array metatable attached or the custom __is_luajson_array metadata key stored.

InitArray(t: table)

Sets the 'array' marker metatable to guarantee the table is represented as a LuaJSON array type.

isCall (t : ANY)

Checks if the passed in object is a LuaJSON call object.

buildCall(name : string, ... parameters)

Builds a call object with the given name and set of parameters. The name is stored in the 'name' field and the parameters in the 'parameters' field as an array.

Additional Utilities

clone (t : table)

Shallow-clones a table by iterating using pairs and assigning.

___printValue (tab : ANY, name : string)

recursively prints out all object values - if duplicates found, reference printed

___merge (t : table, ... : tables)

Shallow-merges a sequence of tables onto table t by iterating over each using pairs and assigning.

Internal Utilities - Not to Use

decodeCall doOptionMerge

Attribution

parsing test suite from JSON_checker project of http://www.json.org/ No listed license for these files in their package.

shortlog
2017-02-01 Thomas Harning Jrall: bump the version reported in the module metadatadevelopmaster
2017-02-01 Thomas Harning Jrbase: prepare release 1.3.41.3.4
2017-02-01 Thomas Harning Jrlicense: updates copyright year
2017-02-01 Thomas Harning JrMerge branch 'feature/updateVersions'
2017-02-01 Thomas Harning Jrdocs: updates README to reflect new test LPEG platform...
2017-02-01 Thomas Harning Jrci: replaces LPEG 1.0.0 testing with 1.0.1 testing
2017-02-01 Thomas Harning Jrci: update used version of LuaRocks
2017-01-16 Thomas Harning JrMerge branch 'feature/cleanupDocs'
2017-01-16 Thomas Harning Jrdocs: cleans up reference for non-present functionality...
2017-01-16 Thomas Harning JrMerge branch 'feature/expandBuildBranches'
2017-01-16 Thomas Harning Jrci: updates travis.yml to allow feature branches
2017-01-16 Thomas Harning JrMerge branch 'feature/allowEmptyElements'
2017-01-16 Thomas Harning Jrdecode+docs+tests: adds support for (array/object/calls...
2017-01-16 Thomas Harning JrMerge branch 'feature/fixTrailingCommaCall'
2017-01-16 Thomas Harning Jrdecode.calls+tests: handle trailingCommas in own settin...
2016-09-10 Thomas Harning JrMerge pull request #36 from retroverse/master
...
tags
22 months ago 1.3.4 luajson 1.3.4
4 years ago 1.3.3 luajson 1.3.3
5 years ago 1.3.2 luajson 1.3.2
6 years ago 1.3.1 luajson 1.3.1
6 years ago 1.3 luajson 1.3
7 years ago pre-1.0 luajson 1.0 pre-release
7 years ago 1.2.2 luajson 1.2.2
7 years ago 1.2.1 luajson 1.2.1
7 years ago 1.2 luajson 1.2
7 years ago 1.1.2 luajson 1.1.2
7 years ago 1.1.1 luajson 1.1.1
7 years ago 1.1 luajson 1.1
7 years ago 1.0.3 luajson 1.0.3
7 years ago 1.0.2 luajson 1.0.2
7 years ago 1.0.1 luajson 1.0.1
7 years ago 1.0 luajson 1.0
...
heads
22 months ago master
22 months ago develop
4 years ago next
4 years ago 1.2.x
4 years ago 1.1.x
4 years ago 1.0.x
6 years ago nonrecursive
7 years ago 1.1.x-utf-encoding