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

Module yaml.tojson

Search:
Group by:

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

Imports

json, streams, strutils, tables, taglib, hints, serialization, stream, ../private/internal, parser

Procs

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

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.

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