TOML
Parsing
Serde.SerdeToml.parse_toml — Function
parse_toml(x::Union{AbstractString, Vector{UInt8}}; kw...) -> Dict{String, Any}Parse a TOML string or byte vector into a Dict{String,Any} without mapping to a target type.
Delegates to the standard library TOML.parse.
Arguments
x: TOML text as aStringorVector{UInt8}.
Returns
A Dict{String, Any} representing the top-level TOML document.
Throws
ParseError: ifxcontains malformed TOML.
Examples
julia> parse_toml("host = \"localhost\"\nport = 8080")
Dict{String, Any}("host" => "localhost", "port" => 8080)See also: from_toml, try_from_toml.
Deserialization
Serde.SerdeToml.from_toml — Function
from_toml(::Type{T}, x; kw...) -> T
from_toml(strategy, ::Type{T}, x; kw...) -> T
from_toml(f::Function, x; kw...) -> AnyParse a TOML string and deserialize it into type T.
Arguments
::Type{T}: target type to construct.x: TOML text as aStringorVector{UInt8}.strategy: optional context object (e.g.CamelCase()).f::Function: function(parsed_data) -> Typefor dynamic type dispatch.
Returns
A value of type T.
Throws
ParseError: ifxis malformed TOML.MissingFieldError: if a required struct field is absent.TypeMismatchError: if a value cannot be coerced to the field type.
Examples
julia> struct Server; host::String; port::Int; end
julia> from_toml(Server, "host = \"localhost\"\nport = 9000")
Server("localhost", 9000)See also: try_from_toml, to_toml, parse_toml.
Serde.SerdeToml.try_from_toml — Function
try_from_toml(::Type{T}, x; kw...) -> Union{T, SerdeError}
try_from_toml(strategy, ::Type{T}, x; kw...) -> Union{T, SerdeError}Like from_toml but returns a SerdeError instead of throwing on failure.
Returns
Ton success.- A
ParseErrororDeserErrorsubtype on failure.
See also: from_toml, SerdeError.
Serialization
Serde.SerdeToml.to_toml — Function
to_toml(data; kw...) -> String
to_toml(strategy, data; kw...) -> StringSerialize data into a TOML string.
Struct fields, dicts, and arrays are mapped to TOML sections, tables, and arrays of tables following TOML conventions. Scalar fields are written as inline key-value pairs; nested structs produce [section] headers.
Pass a context object strategy (e.g. CamelCase()) as the first argument to apply global field-renaming.
All serialization traits (Serde.ser_name, Serde.ser_value, Serde.ser_skip) are applied. Null values (nothing, missing) are omitted.
Arguments
data: value to serialize (struct or dict).strategy: optional context object.
Returns
A TOML-formatted String.
Examples
julia> struct Server; host::String; port::Int; end
julia> to_toml(Server("localhost", 8080)) |> print
host = "localhost"
port = 8080See also: from_toml.