ward.convert
local json = require("ward.convert.json")
local yaml = require("ward.convert.yaml")
local toml = require("ward.convert.toml")
local ini = require("ward.convert.ini")
Common patterns:
encode(value) -> stringdecode(string) -> valueencode_async(value) -> stringdecode_async(string) -> value
Example (JSON):
local json = require("ward.convert.json")
local s = json.encode({ a = 1, b = { true, false } })
local t = json.decode(s)
ward.convert.json
Functions:
json.encode(value, opts?) -> stringjson.decode(text) -> valuejson.encode_async(value, opts?) -> string(runs on a blocking thread)json.decode_async(text) -> value(runs on a blocking thread)
opts for encode/encode_async:
pretty(boolean, defaultfalse) - pretty-print.indent(integer, default2) - spaces per indent level (must be > 0).
ward.convert.yaml
Functions:
yaml.encode(value) -> stringyaml.decode(text) -> valueyaml.encode_async(value) -> string(blocking thread)yaml.decode_async(text) -> value(blocking thread)
ward.convert.toml
Functions:
toml.encode(value) -> stringtoml.decode(text) -> valuetoml.encode_async(value) -> string(blocking thread)toml.decode_async(text) -> value(blocking thread)
ward.convert.ini
Functions:
ini.encode(table) -> stringini.decode(text) -> tableini.encode_async(table) -> string(blocking thread)ini.decode_async(text) -> table(blocking thread)
ini.encode expects a table shaped like:
{
[""] = { root_key = "value" }, -- optional default section
section = { key1 = "v1", flag = true }
}
All values are stringified; booleans/numbers are accepted and converted to strings.