API Reference
ToonFormat.encode — Function
encode(value; options::EncodeOptions = EncodeOptions()) -> StringEncodes value as a TOON document after normalizing it to the JSON data model.
Examples
encode((name = "Ada", age = 30))
# name: Ada
# age: 30
encode([(id = 1,), (id = 2,)])
# [2]{id}:
# 1
# 2ToonFormat.decode — Function
decode(input::AbstractString; options::DecodeOptions = DecodeOptions()) -> JsonValueDecodes a TOON document into OrderedDict{String,Any} objects, Vector{Any} arrays, and String, Int, BigInt, Float64, Bool, or nothing primitives. Throws an ErrorException naming the line on invalid input.
Examples
decode("name: Ada\nage: 30")
# OrderedDict("name" => "Ada", "age" => 30)
decode("[2]: 1,2")
# [1, 2]ToonFormat.EncodeOptions — Type
EncodeOptions(; indentSize = 2, delimiter = COMMA)Options for encode: the spaces per indentation level, and the delimiter of inline arrays and tabular rows – COMMA, TAB, or PIPE.
ToonFormat.DecodeOptions — Type
DecodeOptions(; indentSize = 2, strict = true)Options for decode: the spaces per indentation level, and whether to throw on every decode error of the spec. strict = false applies the spec's five non-strict recoveries instead and throws on every other error.
COMMA, TAB, and PIPE are the exported delimiter constants. Options shows each option in use.