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
.
Available since: v0.0.3
parse
Parses the given input as a JSON string and returns a Lua table containing the equivalent data. Alias for json.decode(...)
.
Available since: v0.0.3Arguments |
---|
# | Name | Type | Fallback |
---|
| jsonString | string | |
Return values |
---|
# | Name | Type |
---|
| luaTable | table |
stringify
Converts the given input table to a JSON string containing the equivalent data. Alias for json.encode(...)
.
Available since: v0.0.3Arguments |
---|
# | Name | Type | Fallback |
---|
| luaTable | table | |
Return values |
---|
# | Name | Type |
---|
| jsonString | string |
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.
Available since: v0.0.3Arguments |
---|
# | Name | Type | Fallback |
---|
| jsonStringOrTable | any | |
Return values |
---|
# | Name | Type |
---|
| prettifiedJSON | string |
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.
Available since: v0.0.3Arguments |
---|
# | Name | Type | Fallback |
---|
| jsonStringOrTable | any | |
Return values |
---|
# | Name | Type |
---|
| prettifiedJSON | string |
Changelog
Version | What happened? |
---|
v0.0.3 | Initial release |