You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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>
<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>
62
+
<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>
<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> representing in Scheme the JSON <code>null</code>. In any other cases, return <code>#f</code>.</p>
<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>
68
+
<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
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>
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>
<li><p><code>'array-open</code> symbol denoting that an array should be constructed.</p></li>
81
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>
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
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>
84
84
</ul></li>
85
85
<li><p>If type is <code>'json-value</code>, then <code>obj</code> is scheme object that can be of the following types:</p>
<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>"null"</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 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>"null"</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>
<p>JSON reader procedure. <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 a scheme object.</p>
119
+
<p>JSON reader procedure. <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 a scheme object.</p>
120
120
<p>The mapping between JSON types and Scheme objects is the following:</p>
121
121
<ul>
122
122
<li><code>null</code> → the symbol <code>'null</code></li>
<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>
131
+
<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>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
149
149
<p>The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.</p>
150
-
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
150
+
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
151
151
<hr>
152
152
<address>Editor: <ahref="mailto:srfi-editors+at+srfi+dot+schemers+dot+org">Arthur A. Gleckler</a></address>
0 commit comments