Skip to main content

json

Lua bindings for the embedded rapidjson library

Status

External: Functionality is provided by a third-party library, which may or may not give semantic versioning guarantees

Availability

This module is preloaded. You can simply require it:

local json = require("json")

Functions

All of the lua-rapidjson APIs are available in this module. Additional functions have been added in Evo, which are listed below.

version

Returns the embedded rapidjson library version as a Lua string. The lua-rapidjson (bindings) version can be queried via _VERSION.

parse

Parses the given input as a JSON string and returns a Lua table containing the equivalent data. Alias for json.decode(...).

stringify

Converts the given input table to a JSON string containing the equivalent data. Alias for json.encode(...).

pretty

Identical to json.encode(...), but accepts both strings and tables. Returns a human-readable JSON string with indentation and key sorting enabled. Indentation uses four spaces (lua-rapidjson default). You probably don't want to use this for performance-critical code.

prettier

Identical to json.pretty, but uses tabs for indentation (instead of four spaces). This saves some space, but is still unsuitable for performance-critical code paths due to the overhead of sorting and possibly redundantly re-encoding the provided string value.

Changelog

VersionWhat happened?
v0.0.3Initial release