1 | == json |
---|
2 | |
---|
3 | === Author |
---|
4 | |
---|
5 | Tony Garnock-Jones |
---|
6 | |
---|
7 | |
---|
8 | === Requirements |
---|
9 | |
---|
10 | * [[http://wiki.call-cc.org/eggref/4/packrat|packrat]] |
---|
11 | |
---|
12 | === Description |
---|
13 | |
---|
14 | This extension implements a parser and generator for the [[http://www.json.org|JSON]] data interchange format. |
---|
15 | |
---|
16 | See also [[json-abnf]] and [[medea]]. |
---|
17 | |
---|
18 | === API |
---|
19 | |
---|
20 | <procedure>(json-write OBJECT [PORT])</procedure> |
---|
21 | |
---|
22 | Writes the Scheme data object {{OBJECT}} in JSON format to {{PORT}} which defaults |
---|
23 | to the value of {{(current-output-port)}}. Scheme data is mapped to JSON format in the following way: |
---|
24 | |
---|
25 | <table> |
---|
26 | <tr><th align="left"> Scheme</th><th align="left">JSON</th></tr> |
---|
27 | <tr><td>Hash-table</td><td>Structure</td></tr> |
---|
28 | <tr><td>Vector</td><td>Structure (assuming vector consists of <tt>(SYMBOL . DATA)</tt> pairs</td></tr> |
---|
29 | <tr><td>List</td><td>Array</td></tr> |
---|
30 | <tr><td>Number</td><td>Number</td></tr> |
---|
31 | <tr><td>Void</td><td>Null</td></tr> |
---|
32 | <tr><td>String or symbol</td><td>String</td></tr> |
---|
33 | </table> |
---|
34 | |
---|
35 | <procedure>(json-read [PORT])</procedure> |
---|
36 | |
---|
37 | Reads data in JSON format from {{PORT}} which defaults to the value of {{(current-input-port)}}. |
---|
38 | |
---|
39 | Note that json-read does not produce alists, as the result are vectors and not lists, and keys are strings and not symbols. |
---|
40 | |
---|
41 | === License |
---|
42 | |
---|
43 | MIT |
---|
44 | |
---|
45 | Copyright (c) 2004, 2005 Tony Garnock-Jones <tonyg@kcbbs.gen.nz> |
---|
46 | Copyright (c) 2005 LShift Ltd. <query@lshift.net> |
---|
47 | |
---|
48 | Permission is hereby granted, free of charge, to any person |
---|
49 | obtaining a copy of this software and associated documentation |
---|
50 | files (the "Software"), to deal in the Software without |
---|
51 | restriction, including without limitation the rights to use, copy, |
---|
52 | modify, merge, publish, distribute, sublicense, and/or sell copies |
---|
53 | of the Software, and to permit persons to whom the Software is |
---|
54 | furnished to do so, subject to the following conditions: |
---|
55 | |
---|
56 | The above copyright notice and this permission notice shall be |
---|
57 | included in all copies or substantial portions of the Software. |
---|
58 | |
---|
59 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
---|
60 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
61 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
62 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
---|
63 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
---|
64 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
---|
65 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
---|
66 | SOFTWARE. |
---|
67 | |
---|
68 | === Version history |
---|
69 | |
---|
70 | ; 1.5 : .meta fixes |
---|
71 | ; 1.3 : ported to CHICKEN 4 |
---|
72 | ; 1.2 : handling of unicode escapes [by Dan Muresan] |
---|
73 | ; 1.1 : Bugfix to handle null |
---|
74 | ; 1.0 : Initial release |
---|