From 898e3df399ba732e3f1f60931cd8edf19ad2ff35 Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Tue, 12 May 2026 21:43:06 -0400 Subject: [PATCH 1/2] doc: Fix playground links and update README.md Unfortunately I lost the playground data when opendylan.org was being moved so here I had to recreate the shared examples. (I've taken steps to do better backups than previously, sigh.) In README.md there's no need to repeat documentation, just link to the actual docs. --- README.md | 51 ++++++---------------------------- documentation/source/index.rst | 29 +++++++++++-------- 2 files changed, 25 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 17b3069..35ce97d 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,23 @@ # JSON -Opendylan library to parse the JSON standard file format. +A library to parse the JSON standard file format. ## Install -Add `json` to your project dependencies +Add `json` to your project dependencies in `dylan-package.json`: ```json "dependencies": [ "json" ], ``` -Update the dependencies: +Update your workspace with the new dependencies: ``` -dylan update +deft update ``` -## Usage +## Documentation -Add `use json;` in the library and module section of your -`library.dylan` file. - -This library exports the following methods: - -- `parse-json` and -- `print-json` - -### Parse JSON - -An example of usage of `parse-json`: - -```dylan -let json = """ - { - "a": 1, - "b": 2 - } - """; - -let json-table = parse-json(json); -format-out("a = %d", json-table["a"]); -``` - -[Run this code](https://play.opendylan.org/shared/d123253033bda66a) in -https://play.opendylan.org - -### Print JSON - -`print-json` is used to pretty print a `table` in JSON format, -following the previous example: - -```dylan -print-json(json-table, *standard-output*, indent: 2); -``` - -[Run a complete example](https://play.opendylan.org/shared/06af84b39fab129b) in -https://play.opendylan.org +Documentation is available in the [Dylan package +docs](https://package.opendylan.org/json/index.html) or it may be read in source form in +`documentation/source/index.rst`. diff --git a/documentation/source/index.rst b/documentation/source/index.rst index d5e00fc..8f1f947 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -90,12 +90,16 @@ Parsing .. code-block:: dylan - let data = """{"a": 1, "b": 2,}"""; - let parsed = parse-json(data, strict?: #f); - let a = parsed["a"]; + let data = """ + { + "a": 1, + "b": 2, + } + """; + let parsed = parse-json(data, strict?: #f); + format-out("%=, %=", parsed["a"], parsed["b"]); - `Run this example `_ - in https://play.opendylan.org + `Run this example `_ Note the use of ``strict?: #f`` is needed since *data* has a trailing comma after the number 2. @@ -115,14 +119,15 @@ Parsing .. code-block:: dylan - with-open-file (fs = "data.json") - let data = parse-json(fs, strict?: #f); - ... - end; + let input = """ + { "x": 123 } + """; + with-input-from-string (stream = input) + let json = parse-json(stream, strict?: #f); + format-out("x is %d", json["x"]); + end; - `Run an example - `_ with a - string stream in https://play.opendylan.org + `Run this example `_ Printing From d299df97747d414ff4e5d90ccb02cfabbce3792e Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Tue, 12 May 2026 21:47:09 -0400 Subject: [PATCH 2/2] Remove registry files from Git Use deft update instead. --- registry/generic/json | 1 - registry/generic/json-test-suite | 1 - 2 files changed, 2 deletions(-) delete mode 100644 registry/generic/json delete mode 100644 registry/generic/json-test-suite diff --git a/registry/generic/json b/registry/generic/json deleted file mode 100644 index 490c2e6..0000000 --- a/registry/generic/json +++ /dev/null @@ -1 +0,0 @@ -abstract://dylan/json.lid diff --git a/registry/generic/json-test-suite b/registry/generic/json-test-suite deleted file mode 100644 index 97039df..0000000 --- a/registry/generic/json-test-suite +++ /dev/null @@ -1 +0,0 @@ -abstract://dylan/tests/json-test-suite.lid