Skip to content
QiTASC.com / intaQt Built-ins /
YAML Built-ins
/ .. /
YAML Built-ins





YAML Built-ins

YAML Built-ins parse YAML files. The created node object is a tree structure, which can be queried.

Encode YAML

This function converts a data object into a YAML-encoded string.

Syntax

1
<resultEncode string> := Yaml.encode(<data Any>)

Returns

A string, which is in YAML form.

Parameter

  • data - The data object to be encoded

Example

1
2
3
4
stepdef "print temperature as YAML"
  map  := {"temperature" : -1, "time" : 18, "day" : "saturday"}
  println(Yaml.encode(map))
end

The example above prints the following string:

1
2
3
4
5
This prints the string
---
temperature: -1
time: 18
day: "saturday"

Decode YAML

This function decodes a YAML string into a data object.

Syntax

1
<resultDecode Any> := Yaml.decode(<encoded String>)

Returns

A decoded object, for example, a map or a list.

Parameter

  • data - The YAML-encoded string to decode

Example

1
2
3
4
5
6
stepdef "print my name"
  myYaml  := "[1, 3, {name: 'Robin'}]"
  decoded := Yaml.decode(myYaml)
  map := decoded[2]
  println(map["name"])
end

The example above decodes the YAML string into a structure. The second element, a map, is extracted, and the name is printed.

PrettyPrint YAML

This function reformats a YAML string into a more human-readable form.

Syntax

1
<pretty String> := Yaml.prettyPrint(<yaml String>)

Returns

A more readable version of the given YAML-encoded string.

Parameter

  • yaml - The YAML content

Example

1
println(Yaml.prettyPrint('{"a":3, "b":4}') )

The example above results in the following output:

1
2
3
---
a: 3
b: 4