Sample code for 30+ languages & platforms
Lua

Create JSON Array of Strings

See more JSON Examples

Demonstrates how to create a JSON array of strings.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- The goal of this example is to produce this:

-- [
--   "tag1",
--   "tag2",
--   "tag3"
-- ]

local jarr = chilkat.JsonArray.new()
jarr:add_string_at(-1, "tag1")
jarr:add_string_at(-1, "tag2")
jarr:add_string_at(-1, "tag3")

jarr.emit_compact = false
print(jarr:emit())