Skip to content

Commit 38fec53

Browse files
Refine English, formatting. Add JSON link.
1 parent e5d2c01 commit 38fec53

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

srfi-180.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,35 @@ <h2 id="author">Author</h2>
5252
<h2 id="status">Status</h2>
5353
<p>Draft</p>
5454
<h2 id="abstract">Abstract</h2>
55-
<p>This library describes a JavaScript Object Notation (<a href="https://www.json.org/">JSON</a>) parser and printer. It does support to stream parse JSON that is possibly bigger than memory.</p>
55+
<p>This library describes a JavaScript Object Notation (JSON) parser and printer. It supports streaming parses of JSON that may be bigger than memory.</p>
5656
<h2 id="rationale">Rationale</h2>
57-
<p>JSON is a defacto industry standard to exchange data.</p>
58-
<p>For best interoperability the sample implementation is based on <a href="https://tools.ietf.org/html/rfc7159">RFC7159</a>, and the tests are based on <a href="https://github.com/nst/JSONTestSuite/">JSONTestSuite</a>.</p>
59-
<p>The mapping between JSON types and Scheme objects is not trivial because a given mapping might not be the best for every situations. That is one of the reason why this library expose a stream reader, in order to allow users to specify the scheme representation and have efficient code.</p>
57+
<p><a href="https://www.json.org/">JSON</a> is a <i>de facto</i> industry standard for data exchange.</p>
58+
<p>For best interoperability, the sample implementation is based on <a href="https://tools.ietf.org/html/rfc7159">RFC7159</a>, and the tests are based on <a href="https://github.com/nst/JSONTestSuite/">JSONTestSuite</a>.</p>
59+
<p>The mapping between JSON types and Scheme objects is not trivial because a given mapping might not be the best for every situation. That is one of the reasons that this library exposes a stream reader, which allows users to specify the Scheme representation and have efficient code.</p>
6060
<h2 id="specification">Specification</h2>
6161
<h3 id="json-error-obj-boolean"><code>(json-error? obj) → boolean</code></h3>
6262
<p>Returns <code>#t</code> is <code>OBJ</code> is an error object. This exception can be raised during <code>json-stream-read</code>, <code>json-read</code> or <code>json-write</code>.</p>
6363
<h3 id="json-error-reason-obj-string"><code>(json-error-reason obj) → string</code></h3>
6464
<p>Return a string explaining the reason for the error. This should be human-readable.</p>
6565
<h3 id="json-null-obj-boolean"><code>(json-null? obj) → boolean</code></h3>
66-
<p>Return <code>#t</code> if <code>OBJ</code> is the scheme symbol <code>'null</code> representing in Scheme the JSON <code>null</code>. In any other cases, return <code>#f</code>.</p>
66+
<p>Return <code>#t</code> if <code>OBJ</code> is the scheme symbol <code>'null</code>, which represents the JSON <code>null</code> in Scheme. In all other cases, return <code>#f</code>.</p>
6767
<h3 id="json-stream-read-proc-port-unspecified"><code>(json-stream-read proc [port]) → unspecified</code></h3>
6868
<p>Streaming event-based JSON reader. <code>PORT</code> must be a textual input port. The default value of <code>PORT</code> is the value returned by the procedure <code>current-input-port</code>. The returned value is unspecified.</p>
69-
<p><code>json-stream-read</code> should raise an object that satisfy the predicate <code>json-error?</code> in cases where the JSON is invalid.</p>
70-
<p><code>json-stream-read</code> will call <code>PROC</code> with two arguments. The first argument is the event <code>type</code>, the second argument is the event <code>obj</code>. Since the value that can be taken by <code>obj</code> depends on the value of <code>type</code>, they are presented together in the following paragraph.</p>
71-
<p>The first arguments is noted <code>type</code>. It is a symbol. It can be the following:</p>
69+
<p><code>json-stream-read</code> should raise an object that satisfies the predicate <code>json-error?</code> in cases where the JSON is invalid.</p>
70+
<p><code>json-stream-read</code> will call <code>PROC</code> with two arguments. The first argument is the event <code>type</code>, and the second argument is the event <code>obj</code>. Since the value that can be taken by <code>obj</code> depends on the value of <code>type</code>, they are presented together in the following paragraph.</p>
71+
<p>The first arguments is denoted <code>type</code>. It is a symbol. It can be the following:</p>
7272
<ul>
7373
<li><code>'json-structure</code></li>
7474
<li><code>'json-value</code></li>
7575
</ul>
76-
<p>The <code>obj</code> argument can take the following values dependings on <code>type</code>:</p>
76+
<p>The <code>obj</code> argument can take the following values depending on <code>type</code>:</p>
7777
<ul>
7878
<li><p>If type is <code>'json-structure</code>, then <code>obj</code> can be:</p>
7979
<ul>
8080
<li><p><code>'array-open</code> symbol denoting that an array should be constructed.</p></li>
81-
<li><p><code>'array-close</code> symbol denoting that the construction of the array for which the last <code>'array-open</code> was emitted and not closed, is finished.</p></li>
82-
<li><p><code>'object-open'</code> symbol denoting that an object should be constructed. The object's key-value pairs are emitted in sequence like property list (plist). The keys will be produced by <code>(proc 'json-structure some-symbol)</code>, that is, the key is always a symbol. The production of the key is always followed by the production of a value. Otherwise, the JSON would be invalid and <code>json-stream-read</code> would raise error. The production of the value can be a <code>'json-value</code> but can also be <code>'json-structure</code> with <code>obj</code> strictly equivalent <code>'array-open</code> or <code>'object-open</code>. This events will be followed by other events. Eventually, an associated <code>'object-close</code> event is emitted.</p></li>
83-
<li><p><code>'object-close</code> symbol denoting that the construction of the object for which the last <code>object-open</code> was emitted and not closed, is finished.</p></li>
81+
<li><p><code>'array-close</code> symbol denoting that the construction of the array for which the last <code>'array-open</code> was emitted and not closed is finished.</p></li>
82+
<li><p><code>'object-open</code> symbol denoting that an object should be constructed. The object's key-value pairs are emitted in sequence like those in a property list (plist). The keys will be produced by <code>(proc 'json-structure some-symbol)</code>, that is, the key is always a symbol. The production of the key is always followed by the production of a value. Otherwise, the JSON would be invalid and <code>json-stream-read</code> would raise error. The production of the value can be a <code>'json-value</code> but can also be <code>'json-structure</code> with <code>obj</code> strictly equivalent <code>'array-open</code> or <code>'object-open</code>. These events will be followed by other events. Eventually, an associated <code>'object-close</code> event is emitted.</p></li>
83+
<li><p><code>'object-close</code> symbol denoting that the construction of the object for which the last <code>object-open</code> was emitted and not closed is finished.</p></li>
8484
</ul></li>
8585
<li><p>If type is <code>'json-value</code>, then <code>obj</code> is scheme object that can be of the following types:</p>
8686
<ul>
@@ -89,12 +89,12 @@ <h3 id="json-stream-read-proc-port-unspecified"><code>(json-stream-read proc [po
8989
<li><p>string</p></li>
9090
</ul></li>
9191
</ul>
92-
<p><strong>Note:</strong> This document does not prescribes a validating parser. But in cases where the input JSON is valid, <code>json-parse</code> must emit the correct sequence of events.</p>
93-
<p><strong>Note:</strong> Given <code>type</code> is <code>'json-value</code>, then there is two occasions where <code>obj</code> can be a symbol: 1) the JSON contains a <code>null</code> value, in that case <code>'null</code> symbol is produced; 2) In a JSON object, keys are produced with the type <code>'json-value</code> and the <code>obj</code> as a symbol. In particular the key <code>&quot;null&quot;</code> will be represented with <code>'null</code> symbol and JSON <code>null</code> too: that does not have bad consequences for the user.</p>
92+
<p><strong>Note:</strong> This document does not prescribe a validating parser. But in cases where the input JSON is valid, <code>json-parse</code> must emit the correct sequence of events.</p>
93+
<p><strong>Note:</strong> Given that <code>type</code> is <code>'json-value</code>, there are two occasions where <code>obj</code> can be a symbol: 1) the JSON contains a <code>null</code> value, in that case <code>'null</code> symbol is produced; 2) In a JSON object, keys are produced with the type <code>'json-value</code> and the <code>obj</code> as a symbol. In particular the key <code>&quot;null&quot;</code> will be represented with <code>'null</code> symbol and JSON <code>null</code> too, but that does not have bad consequences for the user.</p>
9494
<h4 id="example-one">Example One</h4>
9595
<p>Take for instance the following JSON text:</p>
9696
<div class="sourceCode"><pre class="sourceCode javascript"><code class="sourceCode javascript">[<span class="kw">true</span><span class="op">,</span> <span class="kw">false</span><span class="op">,</span> <span class="dv">42</span><span class="op">,</span> <span class="kw">null</span>]</code></pre></div>
97-
<p>It will produce the following calls to <code>PROC</code>:</p>
97+
<p>It will result in the following calls to <code>PROC</code>:</p>
9898
<div class="sourceCode"><pre class="sourceCode scheme"><code class="sourceCode scheme">(proc &#39;json-structure &#39;array-open)
9999
(proc &#39;json-value <span class="dv">#t</span>)
100100
(proc &#39;json-value <span class="dv">#f</span>)
@@ -104,7 +104,7 @@ <h4 id="example-one">Example One</h4>
104104
<h4 id="example-two">Example Two</h4>
105105
<p>Take for instance the following JSON text:</p>
106106
<div class="sourceCode"><pre class="sourceCode javascript"><code class="sourceCode javascript">[<span class="st">&quot;hello&quot;</span><span class="op">,</span> <span class="st">&quot;world&quot;</span><span class="op">,</span> <span class="op">{</span><span class="st">&quot;truth&quot;</span><span class="op">:</span> [<span class="dv">42</span>]<span class="op">}</span>]</code></pre></div>
107-
<p>It will produce the following calls to <code>PROC</code>:</p>
107+
<p>It will result in the following calls to <code>PROC</code>:</p>
108108
<div class="sourceCode"><pre class="sourceCode scheme"><code class="sourceCode scheme">(proc &#39;json-structure &#39;array-open)
109109
(proc &#39;json-value <span class="st">&quot;hello&quot;</span>)
110110
(proc &#39;json-value <span class="st">&quot;world&quot;</span>)
@@ -129,7 +129,7 @@ <h3 id="json-read-port-object"><code>(json-read [port]) → object</code></h3>
129129
</ul>
130130
<h3 id="json-write-obj-port-unspecified"><code>(json-write obj [port]) → unspecified</code></h3>
131131
<p>JSON writer procedure. <code>PORT</code> must be a textual output port. The default value of <code>PORT</code> is the value returned by the procedure <code>current-output-port</code>. The returned value is unspecified.</p>
132-
<p><code>json-write</code> will validate that <code>OBJ</code> can be serialized into JSON before writing to <code>PORT</code>. In the case where <code>OBJ</code> is not an object or composition of the following types, an error that satisfy <code>json-error?</code> is raised:</p>
132+
<p><code>json-write</code> will validate that <code>OBJ</code> can be serialized into JSON before writing to <code>PORT</code>. In the case where <code>OBJ</code> is not an object or composition of the following types, an error that satisfies <code>json-error?</code> is raised:</p>
133133
<ul>
134134
<li>symbol <code>'null</code></li>
135135
<li>boolean</li>
@@ -142,7 +142,7 @@ <h2 id="implementation">Implementation</h2>
142142
<p>The sample implementation is available in <a href="https://github.com/scheme-requests-for-implementation/srfi-180">this Git repo</a>.
143143
</p>
144144
<h2 id="acknowledgements">Acknowledgements</h2>
145-
<p>Give credits where credits is due.</p>
145+
<p>Give credit where credit is due.</p>
146146
<h2 id="copyright">Copyright</h2>
147147
<p>Copyright &copy; 2020 Amirouche Boubekki.</p>
148148
<p>Test files under <code>json/files</code> copyright &copy; 2016 Nicolas Seriot.</p>

0 commit comments

Comments
 (0)