Coming soon toSteam
Modding docsAPI 1

Module · Scripting core

json

Encode Lua values as JSON and parse JSON back. vec3/quat become {x,y,z[,w]} objects and colours "#RRGGBBAA" strings.

json.decode(text: string): any

Parses JSON text. Raises an error for invalid JSON, so wrap it in pcall when the text comes from outside.

local ok, data = pcall(json.decode, text)

json.encode(value: any, pretty?: boolean): string

Encodes a value as JSON text.

  • pretty (optional): Indent the output for reading.
local text = json.encode({ score = 10, tags = { "fast", "red" } }, true)