Load Json

Signature

table loadJson(string path)

Description

Reads a JSON file from a specific path and deserializes its contents into a table.

Returns a table or nil if the file is empty or could not be found.

Arguments

Path

The path of the file to be loaded.

Absolute paths are supported and relative paths start from {game}\x64\.

Example

Load Config

local data = config.loadJson(config.path .. "/mymod-config.json", data)

Input

mymod-config.json
{
    "model": 6488064,
    "name": "Vaan"
}

Notes

Unless a table starts at 1, increases sequentially without gaps, and contains only integer keys, it cannot be reliably traversed in a certain order in Lua.

Last updated