@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
56 lines (55 loc) • 11.7 kB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>JSON encoder and decoder — The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">☰</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="pillow_doc.html">↑</a><a class="lpdoc-navbutton" href="html.html">←</a><a class="lpdoc-navbutton" href="color_space.html">→</a><a class="lpdoc-navbutton" href="ciaosearch.html">🔍</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> »<br/> </li><li><a href="ExtraLibs.html">PART VIII - Additional libraries</a> »<br/> </li><li><a href="pillow_doc.html">Web programming libraries (PiLLoW)</a> »<br/> </li><li><a href=""><strong>JSON encoder and decoder</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>JSON encoder and decoder</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#json"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Jose F. Morales" href="ciaosearch.html#Jose F. Morales">Jose F. Morales</a>.<p>
<div class="lpdoc-alert"><strong>Stability: [</strong><strong>devel</strong><strong>] </strong>Currently the subject of active
development and/or research. Functionality may be limited and API
and/or functionality may change without warning or deprecation period. Not recommended yet for use in production.</div><p><br/>
This module defines a term representation for <a href="http://json.org/">JSON</a> (JavaScript Object Notation), as well as encoders and decoders. <br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(library(pillow/json)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="0" href="#json_to_string/2"><tt>json_to_string/2</tt></a>, <a class="lpdoc-idx-anchor" id="1" href="#string_to_json/2"><tt>string_to_json/2</tt></a>, <a class="lpdoc-idx-anchor" id="2" href="#json_get/3"><tt>json_get/3</tt></a>, <a class="lpdoc-idx-anchor" id="3" href="#json_get_atm/3"><tt>json_get_atm/3</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="#atomiclst_to_json_strlist/2"><tt>atomiclst_to_json_strlist/2</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="#atomic_to_json_str/2"><tt>atomic_to_json_str/2</tt></a>, <a class="lpdoc-idx-anchor" id="6" href="#json_as_atm/2"><tt>json_as_atm/2</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="#json_as_num/2"><tt>json_as_num/2</tt></a>.
<li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="8" href="#json/1"><tt>json/1</tt></a>, <a class="lpdoc-idx-anchor" id="9" href="#json_attrs/1"><tt>json_attrs/1</tt></a>, <a class="lpdoc-idx-anchor" id="10" href="#json_attr/1"><tt>json_attr/1</tt></a>, <a class="lpdoc-idx-anchor" id="11" href="#json_val/1"><tt>json_val/1</tt></a>, <a class="lpdoc-idx-anchor" id="12" href="#json_list/1"><tt>json_list/1</tt></a>.
</ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="json/1" href="ciaosearch.html#json/1">json/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><p>A JSON object. <pre class="lpdoc-codeblock">json(json(Attrs)) :-
json_attrs(Attrs).
</pre></p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="json_attrs/1" href="ciaosearch.html#json_attrs/1">json_attrs/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><p>Attributes (pairs of key/value) of a JSON object. <pre class="lpdoc-codeblock">json_attrs([]).
json_attrs([X|Xs]) :-
json_attr(X),
json_attrs(Xs).
</pre></p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="json_attr/1" href="ciaosearch.html#json_attr/1">json_attr/1</a></div><div class="lpdoc-deftext">A regular type, defined as follows:<pre class="lpdoc-codeblock">json_attr(Id=Val) :-
atm(Id),
json_val(Val).
</pre> </div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="json_val/1" href="ciaosearch.html#json_val/1">json_val/1</a></div><div class="lpdoc-deftext">A regular type, defined as follows:<pre class="lpdoc-codeblock">json_val(string(X)) :-
string(X).
json_val(X) :-
number(X).
json_val(X) :-
json(X).
json_val(X) :-
json_list(X).
json_val(true).
json_val(false).
json_val(null).
</pre> </div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="json_list/1" href="ciaosearch.html#json_list/1">json_list/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><p>A list of JSON elements</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="json_to_string/2" href="ciaosearch.html#json_to_string/2">json_to_string/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>json_to_string(Term,String)</tt>
</span><p>Encode a JSON value <span class="lpdoc-var">Term</span> as a character list.</p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="14" href="#json_val/1"><tt>json:json_val/1</tt></a>)</span><span><a class="lpdoc-idx-anchor" id="13" href="ciaosearch.html#json_val(Term)"><tt>json:json_val(Term)</tt></a>
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="15" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a string (a list of character codes).
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="16" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Term</span> is currently a term which is not a free variable.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="string_to_json/2" href="ciaosearch.html#string_to_json/2">string_to_json/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>string_to_json(String,Term)</tt>
</span><p>Decode a character list as a JSON value <span class="lpdoc-var">Term</span>.</p><ul class="lpdoc-itemize-minus"><li><em>Call and exit should be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="17" href="basic_props.html#string/1"><tt>basic_props:string/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is a string (a list of character codes).
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="19" href="#json_val/1"><tt>json:json_val/1</tt></a>)</span><span><a class="lpdoc-idx-anchor" id="18" href="ciaosearch.html#json_val(Term)"><tt>json:json_val(Term)</tt></a>
</span>
<li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="20" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">String</span> is currently a term which is not a free variable.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="json_get/3" href="ciaosearch.html#json_get/3">json_get/3</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="json_get_atm/3" href="ciaosearch.html#json_get_atm/3">json_get_atm/3</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="atomiclst_to_json_strlist/2" href="ciaosearch.html#atomiclst_to_json_strlist/2">atomiclst_to_json_strlist/2</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="atomic_to_json_str/2" href="ciaosearch.html#atomic_to_json_str/2">atomic_to_json_str/2</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="json_as_atm/2" href="ciaosearch.html#json_as_atm/2">json_as_atm/2</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="json_as_num/2" href="ciaosearch.html#json_as_num/2">json_as_num/2</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p>
</div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="21" href="strings.html"><tt>strings</tt></a>, <a class="lpdoc-idx-anchor" id="22" href="lists.html"><tt>lists</tt></a>.
<li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="23" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="24" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="25" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="26" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="27" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="28" href="regtypes_doc.html"><tt>regtypes</tt></a>, <a class="lpdoc-idx-anchor" id="29" href="basicmodes_doc.html"><tt>basicmodes</tt></a>, <a class="lpdoc-idx-anchor" id="30" href="dcg_doc.html"><tt>dcg</tt></a>, <a class="lpdoc-idx-anchor" id="31" href="fsyntax_doc.html"><tt>fsyntax</tt></a>.
</ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>