src/nyml

Procs

proc `$`(n: YAML): string {....raises: [IOError, OSError, Exception, ValueError,
                                     KeyError, YAMLException, JsonParsingError],
                            tags: [ReadIOEffect, RootEffect, WriteIOEffect],
                            forbids: [].}
Return a stringified JSON
proc parse(n: YAML): Parser {....raises: [IOError, OSError, Exception, ValueError,
                                       KeyError],
                              tags: [ReadIOEffect, RootEffect], forbids: [].}
Parse a new YAML-like document
proc toJson(n: YAML): Document {....raises: [IOError, OSError, Exception,
    ValueError, KeyError, YAMLException, JsonParsingError], tags: [ReadIOEffect,
    RootEffect, WriteIOEffect], forbids: [].}
Parse YAML contents to JsonNode
proc toJsonStr(n: YAML; prettyPrint = false; indent = 2): string {....raises: [
    IOError, OSError, Exception, ValueError, KeyError, YAMLException,
    JsonParsingError], tags: [ReadIOEffect, RootEffect, WriteIOEffect],
    forbids: [].}
Parse YAML contents to stringified JSON
proc toJsonStr(n: YAML; ruler: seq[string]; prettyPrint = false; indent = 2): string {....raises: [
    IOError, OSError, Exception, ValueError, KeyError, YAMLException,
    JsonParsingError], tags: [ReadIOEffect, RootEffect, WriteIOEffect],
    forbids: [].}
YAML parser to JSON string representation, with rules checker
proc toYAML(json: JsonNode): string {....raises: [Exception], tags: [RootEffect],
                                      forbids: [].}
proc toYAML(json: string): string {....raises: [Exception, IOError, OSError,
    JsonParsingError, ValueError], tags: [RootEffect, ReadIOEffect,
    WriteIOEffect], forbids: [].}
proc yaml(contents: string; prettyPrint = false; data: JsonNode = nil): YAML {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Parse a new YAML-like document

Templates

template fromYaml[T: typedesc](str: string; obj: T): untyped
Add support for loose, direct to object parser using https://github.com/treeform/jsony