Class object
LuaJson object class
Functions
| JSON:object ([key[, val[, ...]]]) | Create a new object. |
Methods
| object:tojson () | render an object as valid json |
| object:keys () | Create a new array containing the keys of an object |
Functions
Methods- JSON:object ([key[, val[, ...]]])
-
Create a new object.
Parameters:
- key object key (optional)
- val object val (optional)
- ... next key value pair/s (optional)
Returns:
-
an initialized lua json object
Usage:
local o = JSON:object("test","obj", "age",99, "root",null) print(o.test) --> obj print(o.age) --> 99 print(o.root) --> null
Methods
- object:tojson ()
-
render an object as valid json
Returns:
-
json string
Usage:
print(obj:tojson()) --> {"test":"obj","age":99,"root":null}
- object:keys ()
-
Create a new array containing the keys of an object
Returns:
-
json array of object keys
Usage:
local keys = o:keys() print(keys:tojson())--> ["test","age","root"]