Fork me on GitHub
NimYAML Home Testing Ground Docs: Overview Serialization Modules

Module yaml/tojson

    Dark Mode
Search:
Group by:

The tojson API enables you to parser a YAML character stream into the JSON structures provided by Nim's stdlib.

Imports

data, hints, serialization, stream, internal, parser

Procs

proc constructJson(s: var YamlStream): seq[JsonNode] {...}{.
    raises: [YamlConstructionError, YamlStreamError], tags: [RootEffect].}

Construct an in-memory JSON tree from a YAML event stream. The stream may not contain any tags apart from those in coreTagLibrary. Anchors and aliases will be resolved. Maps in the input must not contain non-scalars as keys. Each element of the result represents one document in the YAML stream.

Warning: The special float values [+-]Inf and NaN will be parsed into Nim's JSON structure without error. However, they cannot be rendered to a JSON character stream, because these values are not part of the JSON specification. Nim's JSON implementation currently does not check for these values and will output invalid JSON when rendering one of these values into a JSON character stream.

proc loadToJson(s: Stream): seq[JsonNode] {...}{.
    raises: [YamlParserError, YamlConstructionError, IOError, OSError],
    tags: [ReadIOEffect, RootEffect].}
Uses YamlParser and constructJson to construct an in-memory JSON tree from a YAML character stream.
proc loadToJson(str: string): seq[JsonNode] {...}{.
    raises: [YamlParserError, YamlConstructionError],
    tags: [ReadIOEffect, RootEffect].}
Uses YamlParser and constructJson to construct an in-memory JSON tree from a YAML character stream.