Class lua

JSON.lua class

Functions

.parse_lua (tname, t) Convert a lua table to a lua json element.
.stringify_lua (tname, elm) Seriaslize a lua table into a parseable json string
.tolua (tname, elm) Convert a lua json element to a table.


Functions

Methods
.parse_lua (tname, t)
Convert a lua table to a lua json element.

Parameters:

  • tname name of new element
  • t lua table

Returns:

    an initialized lua json array or object.

Usage:

    local t = {1,2,3.45,"test",true} -->
    print(t) --> table: 0x5c92968f1c90
    
    local ta = JSON.parse_lua(ta, t)
    print(ta) --> array: 0x5c92968f09a8
    print(ta[0])  --> 1
    print(ta[2])  --> 3.45
    print(ta[#ta]) --> true
.stringify_lua (tname, elm)
Seriaslize a lua table into a parseable json string

Parameters:

  • tname name of new element
  • elm lua json element

Returns:

    lua table

Usage:

    local t = { 1,2,3,4,5 }
    s = JSON.stringify(s, t)
    print(s) --> [1,2,3,4,5]
.tolua (tname, elm)
Convert a lua json element to a table.

Parameters:

  • tname table name
  • elm lua json element

Returns:

    lua table

Usage:

    print(o:tojson()) --> {"some":"data","age":99}
     print(o:tolua()) -->  {some="data",age=99}
generated by LDoc 1.5.0 Last updated 2026-05-09 15:28:03