Skip to content
GAMPEONCreate
New project
Preview: this works today, but details can still change.

Data

Encoding and decoding values.

json.encode(value) --> string

Turn a Lua value into a JSON string. Server and client.

Parameter Type Description
value any Table, string, number, boolean or nil.

Returns

  • string: JSON text.
local text = json.encode({ name = 'Max', cash = 100 })

Compared to FiveM: Same as in FiveM.

json.decode(text) --> any, string?

Turn a JSON string into a Lua value. Server and client.

Parameter Type Description
text string JSON text.

Returns

  • any: The value, or nil if the text is not valid JSON.
  • string?: Error message when decoding failed.
local data, err = json.decode('{"cash": 100}')
if not data then print(err) end

Compared to FiveM: FiveM throws on invalid JSON; GAMPEON returns nil and an error message.

Report a problem with this pageOther ways to give feedback