mirror of
https://github.com/status-im/NimYAML.git
synced 2025-02-05 16:04:48 +00:00
18fc8ba3f5
* removed default value objects, use Nim2 default vaules for fields instead. * moved dump procs to yaml/dumping and introduced Dumper * modified serialization procs to use ctx as first argument, so that prefix calls can be used * changed defaults for presentation to be more like other YAML implementations, e.g. no directives by default. * Removed deprecated procs in DOM API * Removed PresentationStyle – use the setXStyle procs of Dumper instead. * Fixed some warnings emerging from transitioning to Nim2
16 lines
416 B
Nim
16 lines
416 B
Nim
import yaml, streams
|
|
type Mob = object
|
|
level, experience: int32
|
|
drops: seq[string]
|
|
|
|
setTag(Mob, Tag("!Mob"))
|
|
setTag(seq[string], Tag("!Drops"))
|
|
|
|
var mob = Mob(level: 42, experience: 1800, drops:
|
|
@["Sword of Mob Slaying"])
|
|
var s = newFileStream("out.yaml", fmWrite)
|
|
var dumper = Dumper()
|
|
dumper.serialization.tagStyle = tsAll
|
|
dumper.serialization.handles = initNimYamlTagHandle()
|
|
dumper.dump(mob, s)
|
|
s.close() |