Skip to content

Commit d52c431

Browse files
authored
Merge pull request #30 from cgay/dev
Fix doc bugs, remove registry files
2 parents 7e18adf + d299df9 commit d52c431

4 files changed

Lines changed: 25 additions & 57 deletions

File tree

README.md

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,23 @@
11
# JSON
22

3-
Opendylan library to parse the JSON standard file format.
3+
A library to parse the JSON standard file format.
44

55
## Install
66

7-
Add `json` to your project dependencies
7+
Add `json` to your project dependencies in `dylan-package.json`:
88

99
```json
1010
"dependencies": [ "json" ],
1111
```
1212

13-
Update the dependencies:
13+
Update your workspace with the new dependencies:
1414

1515
```
16-
dylan update
16+
deft update
1717
```
1818

19-
## Usage
19+
## Documentation
2020

21-
Add `use json;` in the library and module section of your
22-
`library.dylan` file.
23-
24-
This library exports the following methods:
25-
26-
- `parse-json` and
27-
- `print-json`
28-
29-
### Parse JSON
30-
31-
An example of usage of `parse-json`:
32-
33-
```dylan
34-
let json = """
35-
{
36-
"a": 1,
37-
"b": 2
38-
}
39-
""";
40-
41-
let json-table = parse-json(json);
42-
format-out("a = %d", json-table["a"]);
43-
```
44-
45-
[Run this code](https://play.opendylan.org/shared/d123253033bda66a) in
46-
https://play.opendylan.org
47-
48-
### Print JSON
49-
50-
`print-json` is used to pretty print a `table` in JSON format,
51-
following the previous example:
52-
53-
```dylan
54-
print-json(json-table, *standard-output*, indent: 2);
55-
```
56-
57-
[Run a complete example](https://play.opendylan.org/shared/06af84b39fab129b) in
58-
https://play.opendylan.org
21+
Documentation is available in the [Dylan package
22+
docs](https://package.opendylan.org/json/index.html) or it may be read in source form in
23+
`documentation/source/index.rst`.

documentation/source/index.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ Parsing
9090

9191
.. code-block:: dylan
9292
93-
let data = """{"a": 1, "b": 2,}""";
94-
let parsed = parse-json(data, strict?: #f);
95-
let a = parsed["a"];
93+
let data = """
94+
{
95+
"a": 1,
96+
"b": 2,
97+
}
98+
""";
99+
let parsed = parse-json(data, strict?: #f);
100+
format-out("%=, %=", parsed["a"], parsed["b"]);
96101
97-
`Run this example <https://play.opendylan.org/shared/89037b0be1300a55>`_
98-
in https://play.opendylan.org
102+
`Run this example <https://play.opendylan.org/shared/611eee83bba6d65f>`_
99103

100104
Note the use of ``strict?: #f`` is needed since *data* has a
101105
trailing comma after the number 2.
@@ -115,14 +119,15 @@ Parsing
115119

116120
.. code-block:: dylan
117121
118-
with-open-file (fs = "data.json")
119-
let data = parse-json(fs, strict?: #f);
120-
...
121-
end;
122+
let input = """
123+
{ "x": 123 }
124+
""";
125+
with-input-from-string (stream = input)
126+
let json = parse-json(stream, strict?: #f);
127+
format-out("x is %d", json["x"]);
128+
end;
122129
123-
`Run an example
124-
<https://play.opendylan.org/shared/24c4ac32aaf6a5b5>`_ with a
125-
string stream in https://play.opendylan.org
130+
`Run this example <https://play.opendylan.org/shared/1817e54146dacc16>`_
126131

127132

128133
Printing

registry/generic/json

Lines changed: 0 additions & 1 deletion
This file was deleted.

registry/generic/json-test-suite

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)