Library yaml

To use this library in your code:

import encoding.yaml

Exported classes

Functions

decode bytes/ByteArray [--on-error] -> any
Deprecated. Use decode bytes [--if-error] instead.

decode bytes/ByteArray [--if-error] -> any
Decodes the bytes, which is a ByteArray in single document YAML format.
The result is null, or an instance of int, bool, float, string, List, or Map. The list elements and map values will also be one of these types.

decode bytes/ByteArray -> any
Throws on parse error.

decode bytes/ByteArray --as-stream/any [--on-error] -> List
Deprecated. Use decode bytes --as-stream [--if-error] instead.

decode bytes/ByteArray --as-stream/any [--if-error] -> List
Decodes the bytes, which is a ByteArray in YAML stream format.
The result is a List where each elemenet in the list corresponds to a YAML document from the stream. Each element will be null, or an instance of int, bool, float, string, List, or Map. The list elements and map values will also be one of these types.

decode --as-stream/any bytes/ByteArray -> List
Throws on parse error.

encode obj/any [converter] -> ByteArray
Variant of encode obj.
If the obj is or contains a non-supported type, then the converter block is called with the object and an instance of the YamlEncoder class. The converter is not called for map keys, which must still be strings.
The converter block is passed an object to be serialized and an instance of the YamlEncoder class. If it returns a non-null value, that value will be serialized instead of the object that was passed in. Alternatively, the converter block can call the YamlEncoder.encode, YamlEncoder.put-list, or YamlEncoder.put-unquoted methods on the encoder.

encode obj/any converter/Lambda -> ByteArray
Takes a Lambda instead of a block as converter.

encode obj/any -> ByteArray
Encodes the obj as a YAML ByteArray.
The obj must be a supported type, which means null, or an instance of int, bool, float, string, List or Map.
Maps must have only string keys. The elements of lists and the values of maps can be any of the above supported types.
UTF-8 encoding is used for strings.

encode-stream --writer/Writer obj/any [converter] -> none
If the obj is or contains a non-supported type, then the converter block is called with the object and an instance of the YamlEncoder class. The converter is not called for map keys, which must still be strings.
The converter block is passed an object to be serialized and an instance of the YamlEncoder class. If it returns a non-null value, that value will be serialized instead of the object that was passed in. Alternatively, the converter block can call the YamlEncoder.encode, YamlEncoder.put-list, or YamlEncoder.put-unquoted methods on the encoder.

encode-stream --writer/Writer obj/any converter/Lambda -> none
Takes a Lambda instead of a block as converter.

encode-stream --writer/Writer obj/any -> none
Encodes the obj onto an io.Writer in YAML format.
The obj must be a supported type, which means null, or an instance of int, bool, float, string, List or Map.
Maps must have only string keys. The elements of lists and the values of maps can be any of the above supported types.
UTF-8 encoding is used on the writer.

parse str/string [--on-error] -> any
Deprecated. Use parse str [--if-error] instead.

parse str/string [--if-error] -> any
Decodes the str, which is a string in single document YAML format.
The result is null, or an instance of of int, bool, float, string, List, or Map. The list elements and map values will also be one of these types.

parse str/string -> any
Throws on parse error.

parse str/string --as-stream/any [--on-error] -> List
Deprecated. Use parse str --as-stream [--if-error] instead.

parse str/string --as-stream/any [--if-error] -> List
Decodes the str, which is a string in YAML stream format.
The result is a List where each elemenet in the list corresponds to a YAML document from the stream. Each element will be null, or an instance of int, bool, float, string, List, or Map. The list elements and map values will also be one of these types.

parse --as-stream/any str/string -> List
Throws on parse error.

stringify obj/any [converter] -> string
Variant of stringify obj.
If the obj is or contains a non-supported type, then the converter block is called with the object and an instance of the YamlEncoder class. The converter is not called for map keys, which must still be strings.
The converter block is passed an object to be serialized and an instance of the YamlEncoder class. If it returns a non-null value, that value will be serialized instead of the object that was passed in. Alternatively, the converter block can call the YamlEncoder.encode, YamlEncoder.put-list, or YamlEncoder.put-unquoted methods on the encoder.

stringify obj/any converter/Lambda -> string
Takes a Lambda instead of a block as converter.

stringify obj/any -> string
Encodes the obj as a YAML string.
The obj must be a supported type, which means null, or an instance of int, bool, float, string, List or Map.
Maps must have only string keys. The elements of lists and the values of maps can be any of the above supported types.