Docs
API Reference
Serde

Serializer/Deserializer

ℹ️
Page is being worked on.

Namespaces

  1. json
  2. json5
  3. toml
  4. yaml
  5. gzip
  6. zlib
  7. lz4
  8. base64

json

Functions

  1. json.encode
  2. json.decode

Namespaces

  1. json.Indents
  2. json.Values

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
  1. None
  2. TwoSpaces
  3. FourSpaces
  4. Tabs

None

serde.json.Indents.None: number

TwoSpaces

serde.json.Indents.TwoSpaces: number

FourSpaces

serde.json.Indents.FourSpaces: number

Tabs

serde.json.Indents.Tabs: number

Values

Properties
  1. Null

Null

serde.json.Values.Null: any

json5

Functions

  1. json5.encode
  2. json5.decode

Namespaces

  1. json5.Indents
  2. json5.Values

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
  1. None
  2. TwoSpaces
  3. FourSpaces
  4. Tabs

None

serde.json5.Indents.None: number

TwoSpaces

serde.json5.Indents.TwoSpaces: number

FourSpaces

serde.json5.Indents.FourSpaces: number

Tabs

serde.json5.Indents.Tabs: number

Values

The same as json.Values.

Properties
  1. Null

Null

serde.json5.Values.Null: any

toml

Functions

  1. toml.encode
  2. toml.decode

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

  1. yaml.encode
  2. yaml.decode

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

GenericCompressor

Functions

  1. gzip.compress
  2. gzip.decompress

gzip.compress

serde.gzip.compress(raw: string, options: GenericCompressionOptions?): string
serde.gzip.compress(raw: buffer, options: GenericCompressionOptions?): buffer
️⚠️
Can Error

Compresses a string.

Parameters
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

GenericCompressor

Functions

  1. zlib.compress
  2. zlib.decompress

zlib.compress

serde.zlib.compress(raw: string, options: GenericCompressionOptions?): string
serde.zlib.compress(raw: buffer, options: GenericCompressionOptions?): buffer
️⚠️
Can Error

Compresses a string.

Parameters
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

GenericCompressor

Functions

  1. lz4.compress
  2. lz4.decompress

lz4.compress

serde.lz4.compress(raw: string, options: GenericCompressionOptions?): string
serde.lz4.compress(raw: buffer, options: GenericCompressionOptions?): buffer
️⚠️
Can Error

Compresses a string.

Parameters
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

  1. base64.encode
  2. base64.decode

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,
}