local fs = require("@lune/fs")
local serde = require("@lune/serde")
-- Parse different file formats into lua tables
local someJson = serde.decode("json", fs.readFile("myFile.json"))
local someToml = serde.decode("toml", fs.readFile("myFile.toml"))
local someYaml = serde.decode("yaml", fs.readFile("myFile.yaml"))
-- Write lua tables to files in different formats
fs.writeFile("myFile.json", serde.encode("json", someJson))
fs.writeFile("myFile.toml", serde.encode("toml", someToml))
fs.writeFile("myFile.yaml", serde.encode("yaml", someYaml))
function Serde.decode(format: EncodeDecodeFormat, encoded: string)
Decodes the given string using the given format into a lua value.
function Serde.encode(format: EncodeDecodeFormat, value: any, pretty: boolean?)
Encodes the given value using the given format.
type EncodeDecodeFormat = "json" | "yaml" | "toml"