Module system.serialization.json

JSON encoder/decoder

Index

Data

emptyArray

null

Function

decode()

Parses a JSON string and returns a Lua value represented by the string.

encode()

Serializes an arbitrary Lua object into a JSON string.

load()

Loads a JSON file into a Lua value.

save()

Saves a Lua value to a JSON file.

API Reference

system.serialization.json.null: table
system.serialization.json.emptyArray: table
system.serialization.json.encode(val: any): (result: string)

Serializes an arbitrary Lua object into a JSON string.

Parameters:

val (any) – The value to encode

Returns:

result (string) – The JSON representation of the object

system.serialization.json.decode(str: string, opts?: {binary_escapes: boolean | nil}): (result: any)

Parses a JSON string and returns a Lua value represented by the string.

Parameters:
  • str (string) – The JSON string to decode

  • opts? ({binary_escapes: boolean | nil}) – Any options to pass

Returns:

result (any) – The Lua value from the JSON

system.serialization.json.save(val: any, path: string)

Saves a Lua value to a JSON file.

Parameters:
  • val (any) – The value to save

  • path (string) – The path to the file to save

system.serialization.json.load(path: string): (result: any)

Loads a JSON file into a Lua value.

Parameters:

path (string) – The path to the file to load

Returns:

result (any) – The loaded value