Skip to content

Tables

json

This class enables working with JSON

Methods

  • encode(table)
  • decode(json_string) Returns a table

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Include("system_console")
Include("system_text_json")

local table = {}

console.print("Write your first name: ")
table["first_name"] = console.readln()

console.print("Write your last name:")
table["last_name"] = console.readln()

console.println(json.encode(table))
1
2
3
4
5
6
7
8
9
Include("system_console")
Include("system_text_json")

console.print("Enter JSON data:")
local json = console.readln()
local table = json.decode(json)

console.println("First name is " .. table["first_name"])
console.println("Last name is " .. table["last_name"])

The source code for this library can be found at https://github.com/rxi/json.lua