Serializer/Deserializer
ℹ️
Page is being worked on.
Namespaces
json
Functions
Namespaces
Functions
json.encode
serde.json.encode(value: any, config: JsonEncodeConfig?): string️⚠️
Can Error
Encodes a value to JSON
Parameters
value: any- The value to encode.config:JsonEncodeConfig?- The configuration for the encoding.
Returns
string- The encoded JSON.
Throws
- If the value is invalid, an error will be thrown.
json.decode
serde.json.decode(json: string, config: JsonDecodeConfig?): any️⚠️
Can Error
Decodes JSON
Parameters
json: string- The JSON to decode.config:JsonDecodeConfig?- The configuration for the decoding.
Returns
any- The decoded value.
Throws
- If the JSON is invalid, an error will be thrown.
Namespaces
Indents
Properties
None
serde.json.Indents.None: numberTwoSpaces
serde.json.Indents.TwoSpaces: numberFourSpaces
serde.json.Indents.FourSpaces: numberTabs
serde.json.Indents.Tabs: numberValues
Properties
Null
serde.json.Values.Null: anyjson5
Functions
Namespaces
Functions
json5.encode
serde.json5.encode(value: any, config: JsonEncodeConfig?): string️⚠️
Can Error
Encodes a value to JSON
Parameters
value: any- The value to encode.config:JsonEncodeConfig?- The configuration for the encoding.
Returns
string- The encoded JSON.
Throws
- If the value is invalid, an error will be thrown.
json5.decode
serde.json5.decode(json: string, config: JsonDecodeConfig?): any️⚠️
Can Error
Decodes JSON5
Parameters
json: string- The JSON5 to decode.config:JsonDecodeConfig?- The configuration for the decoding.
Returns
any- The decoded value.
Throws
- If the JSON5 is invalid, an error will be thrown.
Namespaces
Indents
The same as json.Indents.
Properties
None
serde.json5.Indents.None: numberTwoSpaces
serde.json5.Indents.TwoSpaces: numberFourSpaces
serde.json5.Indents.FourSpaces: numberTabs
serde.json5.Indents.Tabs: numberValues
The same as json.Values.
Properties
Null
serde.json5.Values.Null: anytoml
Functions
toml.encode
serde.toml.encode(object: {[string]: any}): string️⚠️
Can Error
Encodes a table to TOML
Parameters
object: {[string]: any}- The table to encode.
Returns
string- The encoded TOML.
Throws
- If the table is invalid, an error will be thrown.
toml.decode
serde.toml.decode(toml: string): {[string]: any}️⚠️
Can Error
Decodes TOML
Parameters
toml: string- The TOML to decode.
Returns
{[string]: any}- The decoded table.
Throws
- If the TOML is invalid, an error will be thrown.
yaml
Functions
yaml.encode
serde.yaml.encode(object: {[string]: any}): string️⚠️
Can Error
Encodes a table to YAML
Parameters
object: {[string]: any}- The table to encode.
Returns
string- The encoded YAML.
Throws
- If the table is invalid, an error will be thrown.
yaml.decode
serde.yaml.decode(yaml: string): {[string]: any}️⚠️
Can Error
Decodes YAML
Parameters
yaml: string- The YAML to decode.
Returns
{[string]: any}- The decoded table.
Throws
- If the YAML is invalid, an error will be thrown.
gzip
Functions
gzip.compress
serde.gzip.compress(raw: string, options: GenericCompressionOptions?): string
serde.gzip.compress(raw: buffer, options: GenericCompressionOptions?): buffer️⚠️
Can Error
Compresses a string.
Parameters
raw: string | buffer- The string/buffer to compress.options:GenericCompressionOptions?- The options for the compression.
Returns
string|buffer- The compressed string/buffer.
Throws
- If the compression fails, an error will be thrown.
- If the options are invalid, an error will be thrown.
gzip.decompress
serde.gzip.decompress(compressed: string): string
serde.gzip.decompress(compressed: buffer): buffer️⚠️
Can Error
Decompresses a string.
Parameters
compressed: string | buffer- The compressed string/buffer to decompress.
Returns
string|buffer- The compressed string/buffer.
Throws
- If the decompression fails, an error will be thrown.
zlib
Functions
zlib.compress
serde.zlib.compress(raw: string, options: GenericCompressionOptions?): string
serde.zlib.compress(raw: buffer, options: GenericCompressionOptions?): buffer️⚠️
Can Error
Compresses a string.
Parameters
raw: string | buffer- The string/buffer to compress.options:GenericCompressionOptions?- The options for the compression.
Returns
string|buffer- The compressed string/buffer.
Throws
- If the compression fails, an error will be thrown.
- If the options are invalid, an error will be thrown.
zlib.decompress
serde.zlib.decompress(compressed: string): string
serde.zlib.decompress(compressed: buffer): buffer️⚠️
Can Error
Decompresses a string.
Parameters
compressed: string | buffer- The compressed string/buffer to decompress.
Returns
string|buffer- The compressed string/buffer.
Throws
- If the decompression fails, an error will be thrown.
lz4
Functions
lz4.compress
serde.lz4.compress(raw: string, options: GenericCompressionOptions?): string
serde.lz4.compress(raw: buffer, options: GenericCompressionOptions?): buffer️⚠️
Can Error
Compresses a string.
Parameters
raw: string | buffer- The string/buffer to compress.options:GenericCompressionOptions?- The options for the compression.
Returns
string|buffer- The compressed string/buffer.
Throws
- If the compression fails, an error will be thrown.
- If the options are invalid, an error will be thrown.
lz4.decompress
serde.lz4.decompress(compressed: string): string
serde.lz4.decompress(compressed: buffer): buffer️⚠️
Can Error
Decompresses a string.
Parameters
compressed: string | buffer- The compressed string/buffer to decompress.
Returns
string|buffer- The compressed string/buffer.
Throws
- If the decompression fails, an error will be thrown.
- If the options are invalid, an error will be thrown.
base64
Functions
base64.encode
serde.base64.encode(value: string): string️⚠️
Can Error
Encodes a string to base64
Parameters
value: string- The string to encode.
Returns
string- The encoded base64.
Throws
- If out of memory, an error will be thrown.
base64.decode
serde.base64.decode(base64: string): string️⚠️
Can Error
Decodes base64
Parameters
base64: string- The base64 to decode.
Returns
string- The decoded string.
Throws
- If the base64 is invalid, an error will be thrown.
- If out of memory, an error will be thrown.
Types
GenericCompressionOptions
export type GenericCompressionOptions = {
--[[
The compression level.
]]
level : number?,
}GenericCompressor
export type GenericCompressor = {
--[[
Compresses a string.
]]
compress :
& ((raw: string, options: GenericCompressionOptions?) -> string)
& ((raw: buffer, options: GenericCompressionOptions?) -> buffer),
--[[
Decompresses a string.
]]
decompress :
& (compressed: string) -> string
& (compressed: buffer) -> buffer,
}Last updated on