mirror of
https://github.com/status-im/NimYAML.git
synced 2025-01-15 14:04:22 +00:00
230 lines
24 KiB
HTML
230 lines
24 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>NimYAML - NimYAML</title>
|
|
|
|
<link href="docutils.css" rel="stylesheet" type="text/css"/>
|
|
<link href="style.css" rel="stylesheet" type="text/css"/>
|
|
|
|
<link href='http://fonts.googleapis.com/css?family=Raleway:400,600,900' rel='stylesheet' type='text/css'/>
|
|
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
|
</head>
|
|
<body>
|
|
<a href="https://github.com/flyx/NimYAML"><img style="position: fixed; top: 0; right: 0; border: 0; z-index: 10;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
|
|
<header>
|
|
<a class="pagetitle" href="index.html">NimYAML</a>
|
|
<a href="index.html">Home</a>
|
|
<a href="testing.html">Testing Ground</a>
|
|
<span>Docs:</span>
|
|
<a href="api.html">Overview</a>
|
|
<a href="serialization.html">Serialization</a>
|
|
<a href="yaml.html">Module yaml</a>
|
|
</header>
|
|
<article id="documentId">
|
|
<div class="container">
|
|
<h1 class="title">NimYAML</h1>
|
|
|
|
<h1 id="introduction">Introduction</h1><p><strong>NimYAML</strong> is a pure YAML implementation for Nim. It is able to read from and write to YAML character streams, and to serialize from and construct to native Nim types. It exclusively supports <a class="reference external" href="#http://www.yaml.org/spec/1.2/spec.html">YAML 1.2</a>.</p>
|
|
<p>Source code can be found on <a class="reference external" href="https://github.com/flyx/NimYAML">GitHub</a>. You can install it with <a class="reference external" href="https://github.com/nim-lang/nimble">Nimble</a>:</p>
|
|
<pre class = "listing">nimble install nimyaml</pre>
|
|
<h1 id="quickstart">Quickstart</h1>
|
|
<h2 id="dumping-nim-objects-as-yaml">Dumping Nim objects as YAML</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>out.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span> <span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">age</span> <span class="Punctuation">:</span> <span class="Identifier">int32</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">personList</span> <span class="Operator">=</span> <span class="Identifier">newSeq</span><span class="Punctuation">[</span><span class="Identifier">Person</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">personList</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">Person</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Karl Koch"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">23</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">personList</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">Person</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Peter Pan"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">12</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"out.yaml"</span><span class="Punctuation">,</span> <span class="Identifier">fmWrite</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">dump</span><span class="Punctuation">(</span><span class="Identifier">personList</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td>
|
|
<td><pre class = "listing">%YAML 1.2
|
|
--- !nim:system:seq(nim:custom:Person)
|
|
-
|
|
name: Karl Koch
|
|
age: 23
|
|
-
|
|
name: Peter Pan
|
|
age: 12</pre></td></tr></tbody></table>
|
|
<h2 id="loading-nim-objects-from-yaml">Loading Nim objects from YAML</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>in.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span> <span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">age</span> <span class="Punctuation">:</span> <span class="Identifier">int32</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">personList</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">Person</span><span class="Punctuation">]</span>
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"in.yaml"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">load</span><span class="Punctuation">(</span><span class="Identifier">s</span><span class="Punctuation">,</span> <span class="Identifier">personList</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td>
|
|
<td><pre class = "listing">%YAML 1.2
|
|
---
|
|
- { name: Karl Koch, age: 23 }
|
|
- { name: Peter Pan, age: 12 }</pre></td></tr></tbody></table>
|
|
<h2 id="customizing-output-style">Customizing output style</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>out.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">age</span><span class="Punctuation">:</span> <span class="Identifier">int32</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">personList</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">Person</span><span class="Punctuation">]</span>
|
|
<span class="Identifier">personList</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">Person</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Karl Koch"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">23</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">personList</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">Person</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Peter Pan"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">12</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"out.yaml"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">dump</span><span class="Punctuation">(</span><span class="Identifier">personList</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">,</span> <span class="Identifier">options</span> <span class="Operator">=</span> <span class="Identifier">defineOptions</span><span class="Punctuation">(</span>
|
|
<span class="Identifier">style</span> <span class="Operator">=</span> <span class="Identifier">psCanonical</span><span class="Punctuation">,</span>
|
|
<span class="Identifier">indentationStep</span> <span class="Operator">=</span> <span class="DecNumber">3</span><span class="Punctuation">,</span>
|
|
<span class="Identifier">newlines</span> <span class="Operator">=</span> <span class="Identifier">nlLF</span><span class="Punctuation">,</span>
|
|
<span class="Identifier">outputVersion</span> <span class="Operator">=</span> <span class="Identifier">ov1_1</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td><td><pre class = "listing">%YAML 1.1
|
|
--- !nim:system:seq(nim:custom:Person)
|
|
[
|
|
!nim:custom:Person {
|
|
? !!str "name"
|
|
: !!str "Karl Koch",
|
|
? !!str "age"
|
|
: !nim:system:int32 "23"
|
|
},
|
|
!nim:custom:Person {
|
|
? !!str "name"
|
|
: !!str "Peter Pan",
|
|
? !!str "age"
|
|
: !nim:system:int32 "12"
|
|
}
|
|
]</pre></td></tr></tbody></table>
|
|
<h2 id="dumping-reference-types-and-cyclic-structures">Dumping reference types and cyclic structures</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>out.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span>
|
|
<span class="Identifier">Node</span> <span class="Operator">=</span> <span class="Keyword">ref</span> <span class="Identifier">NodeObj</span>
|
|
<span class="Identifier">NodeObj</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">left</span><span class="Punctuation">,</span> <span class="Identifier">right</span><span class="Punctuation">:</span> <span class="Identifier">Node</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">node1</span><span class="Punctuation">,</span> <span class="Identifier">node2</span><span class="Punctuation">,</span> <span class="Identifier">node3</span><span class="Punctuation">:</span> <span class="Identifier">Node</span>
|
|
<span class="Identifier">new</span><span class="Punctuation">(</span><span class="Identifier">node1</span><span class="Punctuation">)</span><span class="Punctuation">;</span> <span class="Identifier">new</span><span class="Punctuation">(</span><span class="Identifier">node2</span><span class="Punctuation">)</span><span class="Punctuation">;</span> <span class="Identifier">new</span><span class="Punctuation">(</span><span class="Identifier">node3</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">node1</span><span class="Operator">.</span><span class="Identifier">name</span> <span class="Operator">=</span> <span class="StringLit">"Node 1"</span>
|
|
<span class="Identifier">node2</span><span class="Operator">.</span><span class="Identifier">name</span> <span class="Operator">=</span> <span class="StringLit">"Node 2"</span>
|
|
<span class="Identifier">node3</span><span class="Operator">.</span><span class="Identifier">name</span> <span class="Operator">=</span> <span class="StringLit">"Node 3"</span>
|
|
<span class="Identifier">node1</span><span class="Operator">.</span><span class="Identifier">left</span> <span class="Operator">=</span> <span class="Identifier">node2</span>
|
|
<span class="Identifier">node1</span><span class="Operator">.</span><span class="Identifier">right</span> <span class="Operator">=</span> <span class="Identifier">node3</span>
|
|
<span class="Identifier">node2</span><span class="Operator">.</span><span class="Identifier">right</span> <span class="Operator">=</span> <span class="Identifier">node3</span>
|
|
<span class="Identifier">node3</span><span class="Operator">.</span><span class="Identifier">left</span> <span class="Operator">=</span> <span class="Identifier">node1</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"out.yaml"</span><span class="Punctuation">,</span> <span class="Identifier">fmWrite</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">dump</span><span class="Punctuation">(</span><span class="Identifier">node1</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td><td><pre class = "listing">%YAML 1.2
|
|
--- !nim:custom:NodeObj &a
|
|
name: Node 1
|
|
left:
|
|
name: Node 2
|
|
left: !!null ~
|
|
right: &b
|
|
name: Node 3
|
|
left: *a
|
|
right: !!null ~
|
|
right: *b</pre></td></tr></tbody></table>
|
|
<h2 id="loading-reference-types-and-cyclic-structures">Loading reference types and cyclic structures</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>in.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span>
|
|
<span class="Identifier">Node</span> <span class="Operator">=</span> <span class="Keyword">ref</span> <span class="Identifier">NodeObj</span>
|
|
<span class="Identifier">NodeObj</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">left</span><span class="Punctuation">,</span> <span class="Identifier">right</span><span class="Punctuation">:</span> <span class="Identifier">Node</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">node1</span><span class="Punctuation">:</span> <span class="Identifier">Node</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"in.yaml"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">load</span><span class="Punctuation">(</span><span class="Identifier">s</span><span class="Punctuation">,</span> <span class="Identifier">node1</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td><td><pre class = "listing">%YAML 1.2
|
|
--- !nim:custom:NodeObj &a
|
|
name: Node 1
|
|
left:
|
|
name: Node 2
|
|
left: ~
|
|
right: &b
|
|
name: Node 3
|
|
left: *a
|
|
right: ~
|
|
right: *b</pre></td></tr></tbody></table>
|
|
<h2 id="defining-a-custom-tag-uri-for-a-type">Defining a custom tag uri for a type</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>out.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span> <span class="Identifier">Mob</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">level</span><span class="Punctuation">,</span> <span class="Identifier">experience</span><span class="Punctuation">:</span> <span class="Identifier">int32</span>
|
|
<span class="Identifier">drops</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span>
|
|
|
|
<span class="Identifier">setTagUriForType</span><span class="Punctuation">(</span><span class="Identifier">Mob</span><span class="Punctuation">,</span> <span class="StringLit">"!Mob"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">setTagUriForType</span><span class="Punctuation">(</span><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="StringLit">"!Drops"</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">mob</span> <span class="Operator">=</span> <span class="Identifier">Mob</span><span class="Punctuation">(</span><span class="Identifier">level</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="Identifier">experience</span><span class="Punctuation">:</span> <span class="DecNumber">1800</span><span class="Punctuation">,</span> <span class="Identifier">drops</span><span class="Punctuation">:</span>
|
|
<span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"Sword of Mob Slaying"</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"out.yaml"</span><span class="Punctuation">,</span> <span class="Identifier">fmWrite</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">dump</span><span class="Punctuation">(</span><span class="Identifier">mob</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">,</span>
|
|
<span class="Identifier">options</span> <span class="Operator">=</span> <span class="Identifier">defineOptions</span><span class="Punctuation">(</span><span class="Identifier">tagStyle</span> <span class="Operator">=</span> <span class="Identifier">tsAll</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td><td><pre class = "listing">%YAML 1.2
|
|
--- !Mob
|
|
!!str level: !nim:system:int32 42
|
|
!!str experience: !nim:system:int32 1800
|
|
!!str drops: !Drops [!!str Sword of Mob Slaying]</pre></td></tr></tbody></table>
|
|
<h2 id="dumping-nim-objects-as-json">Dumping Nim objects as JSON</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>out.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span> <span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">age</span> <span class="Punctuation">:</span> <span class="Identifier">int32</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">personList</span> <span class="Operator">=</span> <span class="Identifier">newSeq</span><span class="Punctuation">[</span><span class="Identifier">Person</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">personList</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">Person</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Karl Koch"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">23</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">personList</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">Person</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Peter Pan"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">12</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"out.yaml"</span><span class="Punctuation">,</span> <span class="Identifier">fmWrite</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">dump</span><span class="Punctuation">(</span><span class="Identifier">personList</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">,</span>
|
|
<span class="Identifier">options</span> <span class="Operator">=</span> <span class="Identifier">defineOptions</span><span class="Punctuation">(</span><span class="Identifier">style</span> <span class="Operator">=</span> <span class="Identifier">psJson</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td>
|
|
<td><pre class = "listing">[
|
|
{
|
|
"name": "Karl Koch",
|
|
"age": 23
|
|
},
|
|
{
|
|
"name": "Peter Pan",
|
|
"age": 12
|
|
}
|
|
]</pre></td></tr></tbody></table>
|
|
<h2 id="loading-nim-objects-from-json">Loading Nim objects from JSON</h2><table class="quickstart-example"><thead><tr><th>code.nim</th>
|
|
<th>in.yaml</th></tr></thead><tbody><tr><td><pre class = "listing"><span class="Keyword">import</span> <span class="Identifier">yaml</span>
|
|
<span class="Keyword">type</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Keyword">object</span>
|
|
<span class="Identifier">name</span> <span class="Punctuation">:</span> <span class="Identifier">string</span>
|
|
<span class="Identifier">age</span> <span class="Punctuation">:</span> <span class="Identifier">int32</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">personList</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">Person</span><span class="Punctuation">]</span>
|
|
|
|
<span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="StringLit">"in.yaml"</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">load</span><span class="Punctuation">(</span><span class="Identifier">s</span><span class="Punctuation">,</span> <span class="Identifier">personList</span><span class="Punctuation">)</span>
|
|
<span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></td>
|
|
<td><pre class = "listing">[
|
|
{
|
|
"name": "Karl Koch",
|
|
"age": 23
|
|
},
|
|
{
|
|
"name": "Peter Pan",
|
|
"age": 12
|
|
}
|
|
]</pre></td></tr></tbody></table>
|
|
|
|
|
|
<div class="row">
|
|
<div class="twelve-columns footer">
|
|
<span class="nim-sprite"></span>
|
|
<br/>
|
|
<small>Made with Nim. Generated: 2016-03-21 21:15:51 UTC</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</body>
|
|
</html>
|