feat(types): include and document json5 support in types

This commit is contained in:
Erica Marigold 2024-03-04 12:12:57 +05:30
parent 532409aa25
commit e4c4ea4129
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -1,4 +1,4 @@
export type EncodeDecodeFormat = "json" | "yaml" | "toml" export type EncodeDecodeFormat = "json" | "json5" | "yaml" | "toml"
export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib" export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
@ -18,6 +18,7 @@ export type CompressDecompressFormat = "brotli" | "gzip" | "lz4" | "zlib"
-- Parse different file formats into lua tables -- Parse different file formats into lua tables
local someJson = serde.decode("json", fs.readFile("myFile.json")) local someJson = serde.decode("json", fs.readFile("myFile.json"))
local someJson5 = serde.decode("json5", fs.readFile("myFile.json5"))
local someToml = serde.decode("toml", fs.readFile("myFile.toml")) local someToml = serde.decode("toml", fs.readFile("myFile.toml"))
local someYaml = serde.decode("yaml", fs.readFile("myFile.yaml")) local someYaml = serde.decode("yaml", fs.readFile("myFile.yaml"))
@ -60,11 +61,12 @@ end
Currently supported formats: Currently supported formats:
| Name | Learn More | | Name | Learn More |
|:-------|:---------------------| |:--------|:---------------------|
| `json` | https://www.json.org | | `json` | https://www.json.org |
| `yaml` | https://yaml.org | | `json5` | https://json5.org |
| `toml` | https://toml.io | | `yaml` | https://yaml.org |
| `toml` | https://toml.io |
@param format The format to use @param format The format to use
@param encoded The string to decode @param encoded The string to decode