From dd40c8ebc93ee88d33275bb29e027dd521e8e929 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 13 Jun 2024 18:34:39 +0200 Subject: [PATCH 01/18] Update .gitignore Closes #18 --- .gitignore | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d9abd51..6ee47e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,19 @@ -_build +# backup files +*~ +*.bak +.DS_Store + +# project file *.hdp + +# documentation build directory +/documentation/build/ + +# compiler build directory +/_build/ + +# dylan tool package cache +/_packages/ + +# package registry folder +/registry/ \ No newline at end of file From f84ff95c426c1c193865c86a987236e7cc67b34a Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 13 Jun 2024 18:35:52 +0200 Subject: [PATCH 02/18] Add dependabot Closes #20 --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0d08e26 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From e56b692edb4352f1c6208bde0ac9cbad43b88087 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 13 Jun 2024 19:00:15 +0200 Subject: [PATCH 03/18] Fix error in test suite (table -> tabling) Closes #21 --- tests/library.dylan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/library.dylan b/tests/library.dylan index bd7500d..af28dfe 100644 --- a/tests/library.dylan +++ b/tests/library.dylan @@ -21,7 +21,7 @@ define module json-test-suite use common-dylan; use table-extensions, import: {}, - rename: { table => make-table, + rename: { tabling => make-table, => }; use json; use format, From 65f6c4d7664068590e3bdbd37ba0d01d92fc29d9 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 13 Jun 2024 19:21:57 +0200 Subject: [PATCH 04/18] ci: Update build-and-test action --- .github/workflows/build-and-test.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6c6e021..bbbe91c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -3,10 +3,14 @@ name: build-and-test on: push: # all branches + paths-ignore: + - 'documentation/**' pull_request: branches: - main - master + paths-ignore: + - 'documentation/**' # This enables the Run Workflow button on the Actions tab. workflow_dispatch: @@ -16,11 +20,22 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: dylan-lang/install-opendylan@v2 + - uses: actions/checkout@v4 + + - name: Install Opendylan + uses: dylan-lang/install-opendylan@v3 + + - name: Update dependencies + run: dylan update - name: Build json-test-suite - run: ./dylan-compiler -build -jobs 2 json-test-suite + run: dylan build json-test-suite - name: Run json-test-suite - run: _build/bin/json-test-suite + run: _build/bin/json-test-suite --progress none --report surefire > _build/TEST-json.xml + + - name: Publish Test Report + if: success() || failure() + uses: mikepenz/action-junit-report@v4 + with: + report_paths: '**/_build/TEST-*.xml' From 226300b0f6ee3035c8a91b92c60c7e2ab034ca7a Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 13 Jun 2024 20:30:16 +0200 Subject: [PATCH 05/18] Add README Closes #17 --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..88b24b0 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# JSON + +Opendylan library to parse the JSON standard file format. + +## Install + +Add `json` to your project dependencies + +```json +"dependencies": [ "json" ], +``` + +Update the dependencies: + +``` +dylan update +``` + +## Usage + +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` + +An example of usage of `parse-json`: + +```dylan +// Create a JSON string +let json = #:raw:({ + "a": 1, + "b": 2, +}); + +// Parse JSON to a table +let json-table = parse-json(json); + +format-out("a = %d", json-table["a"]); +``` + +`print-json` is used to pretty print a `table` in JSON format: + +```dylan +print-json(json-table, *standard-output*); +``` From ec0fe19c0c4a6a6738f455029ef66747e81f89d2 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sat, 15 Jun 2024 09:32:46 +0200 Subject: [PATCH 06/18] Add documentation --- documentation/Makefile | 20 +++ documentation/make.bat | 35 ++++++ documentation/source/conf.py | 35 ++++++ documentation/source/index.rst | 38 ++++++ documentation/source/reference.rst | 189 +++++++++++++++++++++++++++++ 5 files changed, 317 insertions(+) create mode 100644 documentation/Makefile create mode 100644 documentation/make.bat create mode 100644 documentation/source/conf.py create mode 100644 documentation/source/index.rst create mode 100644 documentation/source/reference.rst diff --git a/documentation/Makefile b/documentation/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/documentation/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/documentation/make.bat b/documentation/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/documentation/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/documentation/source/conf.py b/documentation/source/conf.py new file mode 100644 index 0000000..e409941 --- /dev/null +++ b/documentation/source/conf.py @@ -0,0 +1,35 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Json' +copyright = '2024, Dylan Hackers' +author = 'Dylan Hackers' +release = '1.1.1' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +import sys, os +sys.path.insert(0, os.path.abspath('../../_packages/sphinx-extensions/current/src/sphinxcontrib')) + +import dylan.themes as dylan_themes +extensions = ['dylan.domain'] + +templates_path = ['_templates'] +exclude_patterns = [] + +primary_domain = 'dylan' + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'furo' +html_static_path = ['_static'] + +# Ignore certification verification +tls_verify = False diff --git a/documentation/source/index.rst b/documentation/source/index.rst new file mode 100644 index 0000000..d4453a9 --- /dev/null +++ b/documentation/source/index.rst @@ -0,0 +1,38 @@ +Welcome to Json's documentation! +================================ + +.. current-library: json + +.. toctree:: + :maxdepth: 2 + :hidden: + + reference + +This library provides essential functionality for working with JSON +data. JSON (JavaScript Object Notation) is a lightweight data +interchange format that is easy for humans to read and write, and easy +for machines to parse and generate. + +The json library offers two primary methods to facilitate the +conversion between JSON strings and OpenDylan tables, making it +straightforward to integrate JSON data handling into your OpenDylan +applications. This methods are: + +:gf:`parse-json` + This method takes a JSON-formatted string and converts it into an + OpenDylan table. This function is useful when you need to process + JSON data received from external sources, such as web APIs or + configuration files. + +:gf:`print-json` + The ``print-json`` function takes an OpenDylan table and converts + it into a formatted JSON string. This is useful for serializing + OpenDylan data structures into JSON format for storage, + transmission, or display purposes. + + +Indices and tables +================== + +* :ref:`genindex` diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst new file mode 100644 index 0000000..e346467 --- /dev/null +++ b/documentation/source/reference.rst @@ -0,0 +1,189 @@ +Json library reference +********************** + +.. current-library:: json +.. current-module:: json + +The json module +=============== + +Constants +--------- + +.. constant:: $null + + Is what "null" parses to. + +Conditions +---------- + +.. class:: + :open: + :instantiable: + + All JSON errors are subclasses of this class. + + :superclasses: :class:`` :drm:`` + +.. class:: + :instantiable: + + Any error signalled during parsing (except for file system errors) + will be an instance of this. + + :superclasses: :class:`` + +``parse-json`` +-------------- + +.. generic-function:: parse-json + :open: + + Parse json formatted text from the given *source*. This is the + main user-visible entry point for parsing. *table-class*, if + provided, should be a subclass of :class:`` to use when + creating a json "object". + + :signature: parse-json (source, #key strict?, table-class) => (json) + :parameter source: An :drm:``. + :parameter #key strict?: An instance of :drm:``. + :parameter #key table-class: Default to :class:``. + :value json: A JSON :drm:`` + + :discussion: + + The parse is strict by default. If ``strict?:`` :drm:`#f` is + used then: + + - `#` is allowed as a comment character + + - "\" is equivalent to ````, where is not a defined + escape character. + + - trailing commas are allowed in arrays and objects + +.. method:: parse-json + :specializer: + + Parse a JSON object from a :drm:``. + + :signature: parse-json (source, #key strict?, table-class) => (json) + :parameter source: An instance of :drm:`` + :parameter #key strict?: An instance of :drm:``. Default to :drm:`#t`. + :parameter #key table-class: A subclass of :class:`
`. + :value json: An instance of :drm:``. + + :example: + + .. code-block:: dylan + + let data = """{"a": 1, "b": 2,}"""; + let parsed = parse-json(data); + let a = parsed["a"]; + +.. method:: parse-json + :specializer: + + Parse a JSON object from a :class:``. + + :signature: parse-json (source, #key strict?, table-class) => (json) + :parameter source: An instance of :class:``. + :parameter #key strict?: An instance of :drm:``. Default to :drm:`#f`. + :parameter #key table-class: A subclass of :class:`
`. + :value json: An instance of :drm:``. + + :example: + + .. code-block:: dylan + + with-open-file (fs = "data.json") + let data = parse-json(fs, strict?: #f); + ... + end; + +``print-json`` +-------------- + +.. function:: print-json + + Print an object in JSON format. + + :signature: print-json (object, stream, #key indent, sort-keys?) => () + :parameter object: The object to print. An instance of :drm:``. + :parameter stream: Stream on wich to do output. An instance of :class:``. + :parameter #key indent: :drm:`#f` or an instance of :drm:``. + :parameter #key sort-keys?: An instance of :drm:``. + + :discussion: + + If `indent` is false, *object* is printed with minimal + whitespace. If an integer, then use pretty printing and output + *indent* spaces for each indent level. + + If `sort-keys:` is true, output object keys in lexicographical + order. + +``do-print-json`` +^^^^^^^^^^^^^^^^^ + +Override this to print your own objects in JSON format. It can be +implemented by converting objects to built-in Dylan types (tables, +collections, etc) and calling *print* on those objects, or by +writing json syntax directly to *stream*. + +If `indent:` was passed to *print* then *stream* will be a pretty +printing stream and the io:pprint module may be used to implement +pretty printing. + +.. generic-function:: do-print-json + :open: + + :signature: do-print-json (object, stream) => () + :parameter object: An instance of :drm:``. + :parameter stream: An instance of :class:``. + +.. method:: do-print-json + :specializer: $null + + :parameter object: $null + :parameter stream: An instance of :class:``. + +.. method:: do-print-json + :specializer: + + Print an :drm:`` in JSON format. + + :parameter object: An instance of :drm:``. + :parameter stream: An instance of :class:``. + +.. method:: do-print-json + :specializer: + + Print a :drm:`` in JSON format. + + :parameter object: An instance of :drm:``. + :parameter stream: An instance of :class:``. + +.. method:: do-print-json + :specializer: + + Print a :drm:`` in JSON format. + + :parameter object: An instance of :drm:``. + :parameter stream: An instance of :class:``. + +.. method:: do-print-json + :specializer: + + Print a :drm:`` in JSON format. + + :parameter object: An instance of :drm:``. + :parameter stream: An instance of :class:``. + +.. method:: do-print-json + :specializer: + + Print a :drm:`` in JSON format. + + :parameter object: An instance of :drm:``. + :parameter stream: An instance of :class:``. From 2483a12d4caa043ee0214cc0ba9a97bd47a9fa50 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sat, 15 Jun 2024 09:37:27 +0200 Subject: [PATCH 07/18] Update library description Update version and add sphinx-extensions as dependency to build the documentation. --- dylan-package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dylan-package.json b/dylan-package.json index a9c5bea..ba0c39c 100644 --- a/dylan-package.json +++ b/dylan-package.json @@ -1,9 +1,9 @@ { "name": "json", - "version": "1.1.0", + "version": "1.1.1", "description": "Convert to/from JSON format", "keywords": ["workspace", "package"], "dependencies": [ "strings@1.2.0" ], - "dev-dependencies": [ "testworks" ], + "dev-dependencies": [ "testworks", "sphinx-extensions" ], "url": "https://github.com/dylan-lang/json" } From 6d686a2eb41307cf400595df336c82017e40a97e Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sat, 15 Jun 2024 09:41:59 +0200 Subject: [PATCH 08/18] Add CI/CD of documentation --- .../build-and-check-documentation.yml | 44 +++++++++++++++ .../build-and-deploy-documentation.yml | 56 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 .github/workflows/build-and-check-documentation.yml create mode 100644 .github/workflows/build-and-deploy-documentation.yml diff --git a/.github/workflows/build-and-check-documentation.yml b/.github/workflows/build-and-check-documentation.yml new file mode 100644 index 0000000..df59976 --- /dev/null +++ b/.github/workflows/build-and-check-documentation.yml @@ -0,0 +1,44 @@ +name: Build and check documentation + +on: + pull_request: + # all branches + paths: + - 'documentation/**' + + # This enables the Run Workflow button on the Actions tab. + workflow_dispatch: + +# Set DYLAN environment variable to GITHUB_WORKSPACE so packages are +# installed in ../../_packages relative to documentation's Makefile +env: + DYLAN: ${{ github.workspace }} + +jobs: + + build-and-deploy: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check links + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/fraya/dylan-docs + options: -v ${{ github.workspace }}/documentation:/docs + run: make linkcheck + + - name: Build docs with Furo theme + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/fraya/dylan-docs + options: -v ${{ github.workspace }}/documentation:/docs + run: make html + + - name: Upload html artifact + uses: actions/upload-artifact@v4 + with: + name: json + path: documentation/build/html/ diff --git a/.github/workflows/build-and-deploy-documentation.yml b/.github/workflows/build-and-deploy-documentation.yml new file mode 100644 index 0000000..28a9858 --- /dev/null +++ b/.github/workflows/build-and-deploy-documentation.yml @@ -0,0 +1,56 @@ +name: Build and deploy documentation + +on: + push: + # all branches + paths: + - 'documentation/**' + + # This enables the Run Workflow button on the Actions tab. + workflow_dispatch: + +# https://github.com/JamesIves/github-pages-deploy-action#readme +permissions: + contents: write + +# Set DYLAN environment variable to GITHUB_WORKSPACE so packages are +# installed in ../../_packages relative to documentation's Makefile +env: + DYLAN: ${{ github.workspace }} + +jobs: + + build-and-deploy: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check links + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/fraya/dylan-docs + options: -v ${{ github.workspace }}/documentation:/docs + run: make linkcheck + + - name: Build docs with Furo theme + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/fraya/dylan-docs + options: -v ${{ github.workspace }}/documentation:/docs + run: make html + + - name: Upload html artifact + uses: actions/upload-artifact@v4 + with: + name: json + path: documentation/build/html/ + + - name: Bypassing Jekyll on GH Pages + run: sudo touch documentation/build/html/.nojekyll + + - name: Deploy docs to GH pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: documentation/build/html From 8711c298c5f93778bdc88a26eed582eacb45306a Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 11:31:46 +0200 Subject: [PATCH 09/18] Improve examples in README Fix error in example and adds links to play.opendylan.org --- README.md | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 88b24b0..17b3069 100644 --- a/README.md +++ b/README.md @@ -26,23 +26,33 @@ This library exports the following methods: - `parse-json` and - `print-json` +### Parse JSON + An example of usage of `parse-json`: ```dylan -// Create a JSON string -let json = #:raw:({ - "a": 1, - "b": 2, -}); +let json = """ + { + "a": 1, + "b": 2 + } + """; -// Parse JSON to a table let json-table = parse-json(json); - format-out("a = %d", json-table["a"]); ``` -`print-json` is used to pretty print a `table` in JSON format: +[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*); +print-json(json-table, *standard-output*, indent: 2); ``` + +[Run a complete example](https://play.opendylan.org/shared/06af84b39fab129b) in +https://play.opendylan.org From e0a960b89fbe4791aced3666e5cf860f548f3ec0 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 11:33:59 +0200 Subject: [PATCH 10/18] doc: Improve description of library purpose --- documentation/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/source/index.rst b/documentation/source/index.rst index d4453a9..3d7eace 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -15,7 +15,7 @@ interchange format that is easy for humans to read and write, and easy for machines to parse and generate. The json library offers two primary methods to facilitate the -conversion between JSON strings and OpenDylan tables, making it +conversion between JSON strings and Dylan data structures, making it straightforward to integrate JSON data handling into your OpenDylan applications. This methods are: From 8d3e0ab73990fdf84cea80d253e9840c25a15a0e Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 11:35:20 +0200 Subject: [PATCH 11/18] doc: Fix library title Short title since this will show up in the ToC sidebar and it needs to be kept short, and should look like the rest of the docs. --- documentation/source/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/source/index.rst b/documentation/source/index.rst index 3d7eace..55c2793 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -1,5 +1,5 @@ -Welcome to Json's documentation! -================================ +json +==== .. current-library: json From 7c61acdd71f2a76a6e00a7cee499c9df31a6b9ed Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 11:38:13 +0200 Subject: [PATCH 12/18] doc: Fix OpenDylan -> Open Dylan --- documentation/source/index.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/source/index.rst b/documentation/source/index.rst index 55c2793..dc3e839 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -16,19 +16,19 @@ for machines to parse and generate. The json library offers two primary methods to facilitate the conversion between JSON strings and Dylan data structures, making it -straightforward to integrate JSON data handling into your OpenDylan +straightforward to integrate JSON data handling into your Open Dylan applications. This methods are: :gf:`parse-json` This method takes a JSON-formatted string and converts it into an - OpenDylan table. This function is useful when you need to process + Open Dylan table. This function is useful when you need to process JSON data received from external sources, such as web APIs or configuration files. :gf:`print-json` - The ``print-json`` function takes an OpenDylan table and converts + The ``print-json`` function takes an Open Dylan table and converts it into a formatted JSON string. This is useful for serializing - OpenDylan data structures into JSON format for storage, + Open Dylan data structures into JSON format for storage, transmission, or display purposes. From c3a40b775c011acac4e7e5d90bd2b3be5583a352 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 11:40:34 +0200 Subject: [PATCH 13/18] doc: Fix title in Reference --- documentation/source/reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index e346467..bcaa216 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -1,4 +1,4 @@ -Json library reference +Json Library Reference ********************** .. current-library:: json From 122a4de5bb5bd01f03791cb24f942153cca3beb3 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 12:47:01 +0200 Subject: [PATCH 14/18] doc: Fix example in 'parse-json' --- documentation/source/reference.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index bcaa216..cda316e 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -78,9 +78,15 @@ Conditions .. code-block:: dylan let data = """{"a": 1, "b": 2,}"""; - let parsed = parse-json(data); + let parsed = parse-json(data, strict?: #f); let a = parsed["a"]; + `Run this example `_ + in https://play.opendylan.org + + Note the use of ``strict?: #f`` is needed since *data* has a + trailing comma after the number 2. + .. method:: parse-json :specializer: From 57caed30bc8e0eb4a3ba4c50fad485b4a09fd706 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 12:48:10 +0200 Subject: [PATCH 15/18] doc: Fix typo in example --- documentation/source/reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index cda316e..34e55b7 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -126,7 +126,7 @@ Conditions whitespace. If an integer, then use pretty printing and output *indent* spaces for each indent level. - If `sort-keys:` is true, output object keys in lexicographical + If `sort-keys?:` is true, output object keys in lexicographical order. ``do-print-json`` From ab588b828af07d84ea1082468165d67741fc1ad8 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 12:49:18 +0200 Subject: [PATCH 16/18] doc: Fix error in method name --- documentation/source/reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index 34e55b7..44a03b4 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -134,7 +134,7 @@ Conditions Override this to print your own objects in JSON format. It can be implemented by converting objects to built-in Dylan types (tables, -collections, etc) and calling *print* on those objects, or by +collections, etc) and calling *print-json* on those objects, or by writing json syntax directly to *stream*. If `indent:` was passed to *print* then *stream* will be a pretty From 1169d120b833dc8789476f81fabbd27a25733f51 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 13:05:31 +0200 Subject: [PATCH 17/18] doc: Add example in play.opendylan --- documentation/source/reference.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index 44a03b4..ffa9f3e 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -107,6 +107,10 @@ Conditions ... end; + `Run an example + `_ with a + string stream in https://play.opendylan.org + ``print-json`` -------------- From c1d891caafa8224d372476085983cfe2a3240674 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Sun, 16 Jun 2024 20:40:06 +0200 Subject: [PATCH 18/18] doc: Change capitalization --- documentation/source/reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index ffa9f3e..9396126 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -1,4 +1,4 @@ -Json Library Reference +json Library Reference ********************** .. current-library:: json