mirror of
https://github.com/c-cube/linol.git
synced 2025-12-10 05:04:00 -05:00
97 lines
37 KiB
HTML
97 lines
37 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Raw (yojson.Yojson.Raw)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">yojson</a> » <a href="../index.html">Yojson</a> » Raw</nav><header class="odoc-preamble"><h1>Module <code><span>Yojson.Raw</span></code></h1><p>Ints, floats and strings literals are systematically preserved using <code>`Intlit</code>, <code>`Floatlit</code> and <code>`Stringlit</code>. This module also supports the specific syntax for variants and tuples supported by <a href="../Safe/index.html"><code>Yojson.Safe</code></a>.</p></header><nav class="odoc-toc"><ul><li><a href="#type-of-the-json-tree">Type of the JSON tree</a></li><li><a href="#json-writers">JSON writers</a></li><li><a href="#miscellaneous">Miscellaneous</a></li><li><a href="#json-pretty-printing">JSON pretty-printing</a></li><li><a href="#json-readers">JSON readers</a></li></ul></nav><div class="odoc-content"><h4 id="type-of-the-json-tree"><a href="#type-of-the-json-tree" class="anchor"></a>Type of the JSON tree</h4><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span><span> = </span><span>[ </span></code><ol><li id="type-t.Null" class="def variant constructor anchored"><a href="#type-t.Null" class="anchor"></a><code><span>| </span><span>`Null</span></code></li><li id="type-t.Bool" class="def variant constructor anchored"><a href="#type-t.Bool" class="anchor"></a><code><span>| </span><span>`Bool <span class="keyword">of</span> bool</span></code></li><li id="type-t.Intlit" class="def variant constructor anchored"><a href="#type-t.Intlit" class="anchor"></a><code><span>| </span><span>`Intlit <span class="keyword">of</span> string</span></code></li><li id="type-t.Floatlit" class="def variant constructor anchored"><a href="#type-t.Floatlit" class="anchor"></a><code><span>| </span><span>`Floatlit <span class="keyword">of</span> string</span></code></li><li id="type-t.Stringlit" class="def variant constructor anchored"><a href="#type-t.Stringlit" class="anchor"></a><code><span>| </span><span>`Stringlit <span class="keyword">of</span> string</span></code></li><li id="type-t.Assoc" class="def variant constructor anchored"><a href="#type-t.Assoc" class="anchor"></a><code><span>| </span><span>`Assoc <span class="keyword">of</span> <span><span>(string * <a href="#type-t">t</a>)</span> list</span></span></code></li><li id="type-t.List" class="def variant constructor anchored"><a href="#type-t.List" class="anchor"></a><code><span>| </span><span>`List <span class="keyword">of</span> <span><a href="#type-t">t</a> list</span></span></code></li><li id="type-t.Tuple" class="def variant constructor anchored"><a href="#type-t.Tuple" class="anchor"></a><code><span>| </span><span>`Tuple <span class="keyword">of</span> <span><a href="#type-t">t</a> list</span></span></code></li><li id="type-t.Variant" class="def variant constructor anchored"><a href="#type-t.Variant" class="anchor"></a><code><span>| </span><span>`Variant <span class="keyword">of</span> string * <span><a href="#type-t">t</a> option</span></span></code></li></ol><code><span> ]</span></code></div><div class="spec-doc"><p>All possible cases defined in Yojson:</p><ul><li>`Null: JSON null</li><li>`Bool of bool: JSON boolean</li><li>`Int of int: JSON number without decimal point or exponent.</li><li>`Intlit of string: JSON number without decimal point or exponent, preserved as a string.</li><li>`Float of float: JSON number, Infinity, -Infinity or NaN.</li><li>`Floatlit of string: JSON number, Infinity, -Infinity or NaN, preserved as a string.</li><li>`String of string: JSON string. Bytes in the range 128-255 are preserved as-is without encoding validation for both reading and writing.</li><li>`Stringlit of string: JSON string literal including the double quotes.</li><li>`Assoc of (string * json) list: JSON object.</li><li>`List of json list: JSON array.</li><li>`Tuple of json list: Tuple (non-standard extension of JSON). Syntax: <code>("abc", 123)</code>.</li><li>`Variant of (string * json option): Variant (non-standard extension of JSON). Syntax: <code><"Foo"></code> or <code><"Bar":123></code>.</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span><span class="keyword">val</span> pp : <span><a href="../../../ocaml/Stdlib/Format/index.html#type-formatter">Stdlib.Format.formatter</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Pretty printer, useful for debugging</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-show"><a href="#val-show" class="anchor"></a><code><span><span class="keyword">val</span> show : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> string</span></code></div><div class="spec-doc"><p>Convert value to string, useful for debugging</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span><span class="keyword">val</span> equal : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p><code>equal a b</code> is the monomorphic equality. Determines whether two JSON values are considered equal. In the case of JSON objects, the order of the keys does not matter, except for duplicate keys which will be considered equal as long as they are in the same input order.</p></div></div><h3 id="json-writers"><a href="#json-writers" class="anchor"></a>JSON writers</h3><div class="odoc-spec"><div class="spec value anchored" id="val-to_string"><a href="#val-to_string" class="anchor"></a><code><span><span class="keyword">val</span> to_string :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <span class="arrow">-></span></span>
|
||
string</span></code></div><div class="spec-doc"><p>Write a compact JSON value to a string.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">buf</span> <p>allows to reuse an existing buffer created with <code>Buffer.create</code>. The buffer is cleared of all contents before starting and right before returning.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">len</span> <p>initial length of the output buffer.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">suf</span> <p>appended to the output as a suffix, defaults to empty string.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">std</span> <p>use only standard JSON syntax, i.e. convert tuples and variants into standard JSON (if applicable), refuse to print NaN and infinities, require the root node to be either an object or an array. Default is <code>false</code>.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <a href="../index.html#exception-Json_error"><code>Json_error</code></a> <p>if <code>float</code> value is not allowed in standard JSON.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_channel"><a href="#val-to_channel" class="anchor"></a><code><span><span class="keyword">val</span> to_channel :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/index.html#type-out_channel">out_channel</a> <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <span class="arrow">-></span></span>
|
||
unit</span></code></div><div class="spec-doc"><p>Write a compact JSON value to a channel. Note: the <code>out_channel</code> is not flushed by this function.</p><p>See <code>to_string</code> for the role of the optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_output"><a href="#val-to_output" class="anchor"></a><code><span><span class="keyword">val</span> to_output :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span><span>< output : <span>string <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int.. ></span> <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <span class="arrow">-></span></span>
|
||
unit</span></code></div><div class="spec-doc"><p>Write a compact JSON value to an OO channel.</p><p>See <code>to_string</code> for the role of the optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_file"><a href="#val-to_file" class="anchor"></a><code><span><span class="keyword">val</span> to_file : <span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span> <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Write a compact JSON value to a file. See <code>to_string</code> for the role of the optional arguments and raised exceptions.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">suf</span> <p>is a suffix appended to the output Newline by default for POSIX compliance.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-to_buffer"><a href="#val-to_buffer" class="anchor"></a><code><span><span class="keyword">val</span> to_buffer : <span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span> <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span><a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Write a compact JSON value to an existing buffer. See <code>to_string</code> for the role of the optional argument and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_to_string"><a href="#val-seq_to_string" class="anchor"></a><code><span><span class="keyword">val</span> seq_to_string :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span><span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span> <span class="arrow">-></span></span>
|
||
string</span></code></div><div class="spec-doc"><p>Write a sequence of <code>suf</code>-suffixed compact one-line JSON values to a string.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">suf</span> <p>is the suffix ouf each value written. Newline by default. See <code>to_string</code> for the role of the optional arguments and raised exceptions.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_to_channel"><a href="#val-seq_to_channel" class="anchor"></a><code><span><span class="keyword">val</span> seq_to_channel :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/index.html#type-out_channel">out_channel</a> <span class="arrow">-></span></span>
|
||
<span><span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span> <span class="arrow">-></span></span>
|
||
unit</span></code></div><div class="spec-doc"><p>Write a sequence of <code>suf</code>-suffixed compact one-line JSON values to a channel.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">suf</span> <p>is the suffix of each value written. Newline by default. See <code>to_channel</code> for the role of the optional arguments and raised exceptions.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_to_file"><a href="#val-seq_to_file" class="anchor"></a><code><span><span class="keyword">val</span> seq_to_file :
|
||
<span><span class="optlabel">?len</span>:int <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<span><span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span> <span class="arrow">-></span></span>
|
||
unit</span></code></div><div class="spec-doc"><p>Write a sequence of <code>suf</code>-suffixed compact one-line JSON values to a file.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">suf</span> <p>is the suffix of each value written. Newline by default. See <code>to_string</code> for the role of the optional arguments and raised exceptions.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_to_buffer"><a href="#val-seq_to_buffer" class="anchor"></a><code><span><span class="keyword">val</span> seq_to_buffer :
|
||
<span><span class="optlabel">?suf</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span> <span class="arrow">-></span></span>
|
||
unit</span></code></div><div class="spec-doc"><p>Write a sequence of <code>suf</code>-suffixed compact one-line JSON values to an existing buffer.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">suf</span> <p>is the suffix of each value written. Newline by default. See <code>to_string</code> for the role of the optional arguments and raised exceptions.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_t"><a href="#val-write_t" class="anchor"></a><code><span><span class="keyword">val</span> write_t : <span><a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Write the given JSON value to the given buffer. Provided as a writer function for atdgen.</p></div></div><h3 id="miscellaneous"><a href="#miscellaneous" class="anchor"></a>Miscellaneous</h3><div class="odoc-spec"><div class="spec value anchored" id="val-sort"><a href="#val-sort" class="anchor"></a><code><span><span class="keyword">val</span> sort : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Sort object fields (stable sort, comparing field names and treating them as byte sequences)</p></div></div><h3 id="json-pretty-printing"><a href="#json-pretty-printing" class="anchor"></a>JSON pretty-printing</h3><div class="odoc-spec"><div class="spec value anchored" id="val-pretty_print"><a href="#val-pretty_print" class="anchor"></a><code><span><span class="keyword">val</span> pretty_print : <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span><a href="../../../ocaml/Stdlib/Format/index.html#type-formatter">Stdlib.Format.formatter</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Pretty-print into a <code>Format.formatter</code>. See <code>to_string</code> for the role of the optional <code>std</code> argument.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <a href="../index.html#exception-Json_error"><code>Json_error</code></a> <p>if <code>float</code> value is not allowed in standard JSON.</p></li></ul><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 1.3.1</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pretty_to_string"><a href="#val-pretty_to_string" class="anchor"></a><code><span><span class="keyword">val</span> pretty_to_string : <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> string</span></code></div><div class="spec-doc"><p>Pretty-print into a string. See <code>to_string</code> for the role of the optional <code>std</code> argument. See <code>pretty_print</code> for raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-pretty_to_channel"><a href="#val-pretty_to_channel" class="anchor"></a><code><span><span class="keyword">val</span> pretty_to_channel : <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span><a href="../../../ocaml/Stdlib/index.html#type-out_channel">out_channel</a> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Pretty-print to a channel. See <code>to_string</code> for the role of the optional <code>std</code> argument. See <code>pretty_print</code> for raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-prettify"><a href="#val-prettify" class="anchor"></a><code><span><span class="keyword">val</span> prettify : <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> string</span></code></div><div class="spec-doc"><p>Combined parser and pretty-printer. See <code>to_string</code> for the role of the optional <code>std</code> argument and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-compact"><a href="#val-compact" class="anchor"></a><code><span><span class="keyword">val</span> compact : <span><span class="optlabel">?std</span>:bool <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> string</span></code></div><div class="spec-doc"><p>Combined parser and printer. See <code>to_string</code> for the role of the optional <code>std</code> argument and raised exceptions.</p></div></div><h3 id="json-readers"><a href="#json-readers" class="anchor"></a>JSON readers</h3><div class="odoc-spec"><div class="spec exception anchored" id="exception-Finally"><a href="#exception-Finally" class="anchor"></a><code><span><span class="keyword">exception</span> </span><span><span class="exception">Finally</span> <span class="keyword">of</span> exn * exn</span></code></div><div class="spec-doc"><p>Exception describing a failure in both finalizer and parsing.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_string"><a href="#val-from_string" class="anchor"></a><code><span><span class="keyword">val</span> from_string :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Read a JSON value from a string.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">buf</span> <p>use this buffer at will during parsing instead of creating a new one.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">fname</span> <p>data file name to be used in error messages. It does not have to be a real file.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">lnum</span> <p>number of the first line of input. Default is 1.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <a href="../index.html#exception-Json_error"><code>Json_error</code></a> <p>if parsing fails.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_channel"><a href="#val-from_channel" class="anchor"></a><code><span><span class="keyword">val</span> from_channel :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/index.html#type-in_channel">in_channel</a> <span class="arrow">-></span></span>
|
||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Read a JSON value from a channel. See <code>from_string</code> for the meaning of the optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_file"><a href="#val-from_file" class="anchor"></a><code><span><span class="keyword">val</span> from_file :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Read a JSON value from a file. See <code>from_string</code> for the meaning of the optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-lexer_state"><a href="#type-lexer_state" class="anchor"></a><code><span><span class="keyword">type</span> lexer_state</span><span> = </span><span>{</span></code><ol><li id="type-lexer_state.buf" class="def record field anchored"><a href="#type-lexer_state.buf" class="anchor"></a><code><span>buf : <a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a>;</span></code></li><li id="type-lexer_state.lnum" class="def record field anchored"><a href="#type-lexer_state.lnum" class="anchor"></a><code><span><span class="keyword">mutable</span> lnum : int;</span></code></li><li id="type-lexer_state.bol" class="def record field anchored"><a href="#type-lexer_state.bol" class="anchor"></a><code><span><span class="keyword">mutable</span> bol : int;</span></code></li><li id="type-lexer_state.fname" class="def record field anchored"><a href="#type-lexer_state.fname" class="anchor"></a><code><span><span class="keyword">mutable</span> fname : <span>string option</span>;</span></code></li></ol><code><span>}</span></code></div><div class="spec-doc"><p>This alias is provided for backward compatibility. New code should refer to <a href="../index.html#type-lexer_state"><code>Yojson.lexer_state</code></a> directly.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-init_lexer"><a href="#val-init_lexer" class="anchor"></a><code><span><span class="keyword">val</span> init_lexer :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span>unit <span class="arrow">-></span></span>
|
||
<a href="#type-lexer_state">lexer_state</a></span></code></div><div class="spec-doc"><p>This alias is provided for backward compatibility. New code should use <a href="../index.html#val-init_lexer"><code>Yojson.init_lexer</code></a> directly.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-from_lexbuf"><a href="#val-from_lexbuf" class="anchor"></a><code><span><span class="keyword">val</span> from_lexbuf : <span><a href="#type-lexer_state">lexer_state</a> <span class="arrow">-></span></span> <span><span class="optlabel">?stream</span>:bool <span class="arrow">-></span></span> <span><a href="../../../ocaml/Stdlib/Lexing/index.html#type-lexbuf">Stdlib.Lexing.lexbuf</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Read a JSON value from a lexbuf. A valid initial <code>lexer_state</code> can be created with <code>init_lexer</code>. See <code>from_string</code> for the meaning of the optional arguments and raised exceptions.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">stream</span> <p>indicates whether more data may follow. The default value is false and indicates that only JSON whitespace can be found between the end of the JSON value and the end of the input.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_from_string"><a href="#val-seq_from_string" class="anchor"></a><code><span><span class="keyword">val</span> seq_from_string :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Input a sequence of JSON values from a string. Whitespace between JSON values is fine but not required. See <code>from_string</code> for the meaning of the optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_from_channel"><a href="#val-seq_from_channel" class="anchor"></a><code><span><span class="keyword">val</span> seq_from_channel :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fin</span>:<span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/index.html#type-in_channel">in_channel</a> <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Input a sequence of JSON values from a channel. Whitespace between JSON values is fine but not required.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">fin</span> <p>finalization function executed once when the end of the sequence is reached either because there is no more input or because the input could not be parsed, raising an exception.</p></li></ul><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <a href="#exception-Finally"><code>Finally</code></a> <p>When the parsing and the finalizer both raised, <code>Finally (exn, fin_exn)</code> is raised, <code>exn</code> being the parsing exception and <code>fin_exn</code> the finalizer one.</p><p>See <code>from_string</code> for the meaning of the other optional arguments and other raised exceptions.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_from_file"><a href="#val-seq_from_file" class="anchor"></a><code><span><span class="keyword">val</span> seq_from_file :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Input a sequence of JSON values from a file. Whitespace between JSON values is fine but not required.</p><p>See <code>from_string</code> for the meaning of the optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-seq_from_lexbuf"><a href="#val-seq_from_lexbuf" class="anchor"></a><code><span><span class="keyword">val</span> seq_from_lexbuf :
|
||
<span><a href="#type-lexer_state">lexer_state</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fin</span>:<span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/Lexing/index.html#type-lexbuf">Stdlib.Lexing.lexbuf</a> <span class="arrow">-></span></span>
|
||
<span><a href="#type-t">t</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Input a sequence of JSON values from a lexbuf. A valid initial <code>lexer_state</code> can be created with <code>init_lexer</code>. Whitespace between JSON values is fine but not required.</p><ul class="at-tags"><li class="raises"><span class="at-tag">raises</span> <a href="#exception-Finally"><code>Finally</code></a> <p>When the parsing and the finalizer both raised, <code>Finally (exn, fin_exn)</code> is raised, <code>exn</code> being the parsing exception and <code>fin_exn</code> the finalizer one.</p><p>See <code>seq_from_channel</code> for the meaning of the optional <code>fin</code> argument and other raised exceptions.</p></li></ul></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-json_line"><a href="#type-json_line" class="anchor"></a><code><span><span class="keyword">type</span> json_line</span><span> = </span><span>[ </span></code><ol><li id="type-json_line.Json" class="def variant constructor anchored"><a href="#type-json_line.Json" class="anchor"></a><code><span>| </span><span>`Json <span class="keyword">of</span> <a href="#type-t">t</a></span></code></li><li id="type-json_line.Exn" class="def variant constructor anchored"><a href="#type-json_line.Exn" class="anchor"></a><code><span>| </span><span>`Exn <span class="keyword">of</span> exn</span></code></li></ol><code><span> ]</span></code></div><div class="spec-doc"><p>The type of values resulting from a parsing attempt of a JSON value.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-lineseq_from_channel"><a href="#val-lineseq_from_channel" class="anchor"></a><code><span><span class="keyword">val</span> lineseq_from_channel :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fin</span>:<span>(<span>unit <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span><a href="../../../ocaml/Stdlib/index.html#type-in_channel">in_channel</a> <span class="arrow">-></span></span>
|
||
<span><a href="#type-json_line">json_line</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Input a sequence of JSON values, one per line, from a channel. Exceptions raised when reading malformed lines are caught and represented using <code>`Exn</code>.</p><p>See <code>seq_from_channel</code> for the meaning of the optional <code>fin</code> argument. See <code>from_string</code> for the meaning of the other optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-lineseq_from_file"><a href="#val-lineseq_from_file" class="anchor"></a><code><span><span class="keyword">val</span> lineseq_from_file :
|
||
<span><span class="optlabel">?buf</span>:<a href="../../../ocaml/Stdlib/Buffer/index.html#type-t">Stdlib.Buffer.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?fname</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?lnum</span>:int <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<span><a href="#type-json_line">json_line</a> <a href="../../../ocaml/Stdlib/Seq/index.html#type-t">Stdlib.Seq.t</a></span></span></code></div><div class="spec-doc"><p>Input a sequence of JSON values, one per line, from a file. Exceptions raised when reading malformed lines are caught and represented using <code>`Exn</code>.</p><p>See <code>seq_from_channel</code> for the meaning of the optional <code>fin</code> argument. See <code>from_string</code> for the meaning of the other optional arguments and raised exceptions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-read_t"><a href="#val-read_t" class="anchor"></a><code><span><span class="keyword">val</span> read_t : <span><a href="#type-lexer_state">lexer_state</a> <span class="arrow">-></span></span> <span><a href="../../../ocaml/Stdlib/Lexing/index.html#type-lexbuf">Stdlib.Lexing.lexbuf</a> <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Read a JSON value from the given lexer_state and lexing buffer and return it. Provided as a reader function for atdgen.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Util"><a href="#module-Util" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Util/index.html">Util</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>This module provides combinators for extracting fields from JSON values.</p></div></div></div></body></html>
|