File: README.md

package info (click to toggle)
lua-json 1.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 652 kB
  • sloc: makefile: 67; php: 3
file content (115 lines) | stat: -rw-r--r-- 3,029 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
## 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:
* Lua 5.1.5
* Lua 5.2.4
* Lua 5.3.4
* LuaJIT-2.0.4
* LuaJIT-2.1.0-beta2

### 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

### 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.