JSON parser/encoder for Lua Parses JSON using LPEG for speed and flexibility. Depending on parser/encoder options, various values are preserved as best as possible.
Lua PHP
Pull request Compare This branch is 10 commits ahead, 69 commits behind harningt:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
cmake
dist
docs
lua
rockspecs
tests
util
.travis.yml
CMakeLists.txt
LICENSE
Makefile
README
ReleaseNotes.txt
dist.info

README

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, or LuaJIT 2.0
	LPeg (Tested with 0.7, 0.8, 0.9, 0.10, 0.12rc2 ... 0.6 mostly works)
	For regressionTest:
		lfs (Tested with 1.4.1)
	For lunit-tests:
		lunit >= 0.4

NOTE: LPeg 0.11 may not work - it crashed during my tests

Lua versions tested recently:
    Lua 5.1.4 + strict + pl.strict
    Lua 5.2.0 + pl.strict
    LuaJIT-2.0.0-beta10 + strict + pl.strict

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
			array-like table (spec below)
			string
			number
			boolean
			'null' - represented by json.util.null
		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
	--isEncodable ( value : ANY )
		Returns a boolean stating whether is is encodeable or not
		NOTE: Tables/arrays are not deeply inspected

	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
	--printValue (tab : ANY, name : string)
			recursively prints out all object values - if duplicates found, reference printed
	--null
			Reference value to represent 'null' in a well-defined way to
			allow for null values to be inserted into an array/table
	--merge (t : table, ... : tables)
			Shallow-merges a sequence of tables onto table t by iterating over each using
			pairs and assigning.

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