json.encode(table [,compatible])
Convert a Lua table into a JSON encoded string. The special value
json.NULL can be used to store a null value in a Lua table since it is not possible
to store a Lua null value in a table.
t = {111,222,333,foo="abc"}
Using json.encode(t) on this table yields the string
'{1:111,2:222,3:333,"foo":"abc"}' which is not a legal encoding for JSON, whereas
json.encode(t,true) yields the string '{"1":111,"2":222,"3":333,"foo":"abc"}'. In
the compatible format, all of the integer keys of the table are converted to string keys.
json.encode function makes no attempt to detect recursive tables, therefore
the code shown below will result in a stack overflow
error.t = {1,2,3}
t[4] = t
str = json.encode(t)
Examplet = {a=123,b=987,c=333,d=json.NULL}
str = json.encode(t)