9951 explained code solutions for 126 technologies


luaHow to convert table to JSON string


We'll use cjson module to convert table to string representation:

local cjson = require "cjson"
local json_str = cjson.encode(tbl)ctrl + c
require "cjson"

load cjson module to work with JSON

cjson.encode

encodes given table to JSON string

tbl

table to encode to JSON string

json_str

resulting JSON string