···2929 "name": "Alice", age: 30
3030 "age": 30, active: true
3131 "active": true
3232-}</pre><p>The YAML version is cleaner for humans to read and write.</p><h2 id="setup"><a href="#setup" class="anchor"></a>Setup</h2><p>First, let's set up our environment. The library is loaded with:</p><div class="x-ocaml-wrapper"><x-ocaml>#require "yamlrw";;
3333-open Yamlrw;;</x-ocaml></div><h2 id="basic-parsing"><a href="#basic-parsing" class="anchor"></a>Basic Parsing</h2><p>The simplest way to parse YAML is with <code>Yamlrw.of_string</code>:</p><div class="x-ocaml-wrapper"><x-ocaml>let simple = of_string "hello";;</x-ocaml></div><p>YAML automatically recognizes different data types:</p><div class="x-ocaml-wrapper"><x-ocaml>of_string "42";;
3232+}</pre><p>The YAML version is cleaner for humans to read and write.</p><h2 id="setup"><a href="#setup" class="anchor"></a>Setup</h2><p>First, let's set up our environment. The library is loaded with:</p><div class="x-ocaml-wrapper"><x-ocaml>open Yamlrw;;</x-ocaml></div><h2 id="basic-parsing"><a href="#basic-parsing" class="anchor"></a>Basic Parsing</h2><p>The simplest way to parse YAML is with <code>Yamlrw.of_string</code>:</p><div class="x-ocaml-wrapper"><x-ocaml>let simple = of_string "hello";;</x-ocaml></div><p>YAML automatically recognizes different data types:</p><div class="x-ocaml-wrapper"><x-ocaml>of_string "42";;
3433of_string "3.14";;
3534of_string "true";;
3635of_string "null";;</x-ocaml></div><p>Note that integers are stored as floats in the JSON-compatible <code>Yamlrw.value</code> type, matching the behavior of JSON parsers.</p><h3 id="boolean-values"><a href="#boolean-values" class="anchor"></a>Boolean Values</h3><p>YAML recognizes many forms of boolean values:</p><div class="x-ocaml-wrapper"><x-ocaml>of_string "yes";;
+1-2
doc/tutorial.html
···44 "name": "Alice", age: 30
55 "age": 30, active: true
66 "active": true
77-}</pre><p>The YAML version is cleaner for humans to read and write.</p><h2 id="setup"><a href="#setup" class="anchor"></a>Setup</h2><p>First, let's set up our environment. The library is loaded with:</p><pre class="language-ocaml"><code># #require "yamlrw";;
88-# open Yamlrw;;</code></pre><h2 id="basic-parsing"><a href="#basic-parsing" class="anchor"></a>Basic Parsing</h2><p>The simplest way to parse YAML is with <code>Yamlrw.of_string</code>:</p><pre class="language-ocaml"><code># let simple = of_string "hello";;
77+}</pre><p>The YAML version is cleaner for humans to read and write.</p><h2 id="setup"><a href="#setup" class="anchor"></a>Setup</h2><p>First, let's set up our environment. The library is loaded with:</p><pre class="language-ocaml"><code># open Yamlrw;;</code></pre><h2 id="basic-parsing"><a href="#basic-parsing" class="anchor"></a>Basic Parsing</h2><p>The simplest way to parse YAML is with <code>Yamlrw.of_string</code>:</p><pre class="language-ocaml"><code># let simple = of_string "hello";;
98val simple : value = `String "hello"</code></pre><p>YAML automatically recognizes different data types:</p><pre class="language-ocaml"><code># of_string "42";;
109- : value = `Float 42.
1110# of_string "3.14";;
-1
doc/tutorial.mld
···3838First, let's set up our environment. The library is loaded with:
39394040{@ocaml[
4141-# #require "yamlrw";;
4241# open Yamlrw;;
4342]}
4443