2021-05-17 22:31:47 +00:00
|
|
|
import yaml/serialization, yaml/presenter, streams
|
2016-10-08 16:38:27 +00:00
|
|
|
type Person = object
|
|
|
|
name: string
|
|
|
|
age: int32
|
|
|
|
|
2016-10-08 21:35:33 +00:00
|
|
|
var personList = newSeq[Person]()
|
2016-10-08 16:38:27 +00:00
|
|
|
personList.add(Person(name: "Karl Koch", age: 23))
|
|
|
|
personList.add(Person(name: "Peter Pan", age: 12))
|
|
|
|
|
2016-10-08 21:35:33 +00:00
|
|
|
var s = newFileStream("out.yaml", fmWrite)
|
2016-10-08 16:38:27 +00:00
|
|
|
dump(personList, s, options = defineOptions(
|
|
|
|
style = psCanonical,
|
|
|
|
indentationStep = 3,
|
|
|
|
newlines = nlLF,
|
|
|
|
outputVersion = ov1_1))
|
|
|
|
s.close()
|