diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7868e80 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# inform linguist that files with these extensions are indeed smalltalk files +*.st linguist-language=Smalltalk +*.gs linguist-language=Smalltalk diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..774b17d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: Build + +on: [ push, pull_request, workflow_dispatch ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + smalltalk: [ Pharo64-13, Pharo64-12, Pharo64-11, Pharo64-10, Pharo64-9.0, Pharo64-8.0, Pharo64-7.0 ] + name: ${{ matrix.smalltalk }} + steps: + - uses: actions/checkout@v2 + - name: Set up Smalltalk CI + uses: hpi-swa/setup-smalltalkCI@v1 + with: + smalltalk-image: ${{ matrix.smalltalk }} + - name: Load Image and Run Tests + run: smalltalkci -s ${{ matrix.smalltalk }} .smalltalkci/.unit-tests.ston + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + timeout-minutes: 15 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + name: ${{matrix.os}}-${{matrix.smalltalk}} + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..44f888f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: smalltalkCI + +on: + push: + pull_request: + branches: + gemstone + schedule: + - cron: "15 2 9 * *" #run job on the 9th day of every month on the 15th minute of the 2nd hour + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + smalltalk: [ GemStone64-3.7.2, GemStone64-3.7.4.3 ] + runs-on: ${{ matrix.os }} + name: ${{ matrix.smalltalk }} + steps: + - uses: actions/checkout@v2 + - uses: hpi-swa/setup-smalltalkCI@v1 + with: + smalltalk-image: ${{ matrix.smalltalk }} + - name: Run tests + run: smalltalkci -s ${{ matrix.smalltalk }} + shell: bash + timeout-minutes: 20 + slack-workflow-status: + if: always() + name: Post Workflow Status To Slack + needs: + - build + runs-on: ubuntu-latest + steps: + - name: Slack Workflow Notification + uses: Gamesight/slack-workflow-status@master + with: + repo_token: ${{secrets.GITHUB_TOKEN}} + slack_webhook_url: ${{secrets.SLACK_DALEHENRICH}} + name: 'action run' diff --git a/.nix/flake.lock b/.nix/flake.lock new file mode 100644 index 0000000..9ade815 --- /dev/null +++ b/.nix/flake.lock @@ -0,0 +1,85 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "type": "github" + }, + "original": { + "owner": "numtide", + "ref": "v1.0.0", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "type": "github" + }, + "original": { + "owner": "numtide", + "ref": "v1.0.0", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744664988, + "narHash": "sha256-tv5QkwoHUT7957XYPOWpyBD440SdfPBPBVymbXlmqsc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eff64d6c1a13c9a3348f332f75cbde1935dc3d21", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "pharo-vm-12": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "dir": "pharo-vm", + "lastModified": 1744567847, + "narHash": "sha256-Am5h1E69nFUdjD+XDFRw7wB3Lr2k2bxrRKygy96LJCA=", + "owner": "rydnr", + "repo": "nix-flakes", + "rev": "6369c686e0d7d974e0de93685bd4b16615bb5113", + "type": "github" + }, + "original": { + "dir": "pharo-vm", + "owner": "rydnr", + "ref": "pharo-vm-12.0.1519.2", + "repo": "nix-flakes", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pharo-vm-12": "pharo-vm-12" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/.nix/flake.nix b/.nix/flake.nix new file mode 100644 index 0000000..b1cfc1b --- /dev/null +++ b/.nix/flake.nix @@ -0,0 +1,122 @@ +{ + description = "Flake for svenvc/neojson"; + + inputs = rec { + flake-utils.url = "github:numtide/flake-utils/v1.0.0"; + nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; + pharo-vm-12 = { + inputs.nixpkgs.follows = "nixpkgs"; + url = "github:rydnr/nix-flakes/pharo-vm-12.0.1519.2?dir=pharo-vm"; + }; + }; + outputs = inputs: + with inputs; + flake-utils.lib.eachDefaultSystem (system: + let + org = "svenvc"; + repo = "neojson"; + pname = "${repo}"; + tag = "v18"; + baseline = "NeoJSON"; + pkgs = import nixpkgs { inherit system; }; + description = "An elegant and efficient Smalltalk framework to read and write JSON converting to or from Smalltalk objects"; + license = pkgs.lib.licenses.mit; + homepage = "https://github.com/svenvc/neojson"; + maintainers = with pkgs.lib.maintainers; [ ]; + nixpkgsVersion = builtins.readFile "${nixpkgs}/.version"; + nixpkgsRelease = + builtins.replaceStrings [ "\n" ] [ "" ] "nixpkgs-${nixpkgsVersion}"; + shared = import ./shared.nix; + svenvc-neojson-for = { bootstrap-image-name, bootstrap-image-sha256, bootstrap-image-url, pharo-vm }: + let + bootstrap-image = pkgs.fetchurl { + url = bootstrap-image-url; + sha256 = bootstrap-image-sha256; + }; + src = ./../repository; + in pkgs.stdenv.mkDerivation (finalAttrs: { + version = tag; + inherit pname src; + + strictDeps = true; + + buildInputs = with pkgs; [ + ]; + + nativeBuildInputs = with pkgs; [ + pharo-vm + pkgs.unzip + ]; + + unpackPhase = '' + unzip -o ${bootstrap-image} -d image + # cp -r ${src} src + ''; + + configurePhase = '' + runHook preConfigure + + # load baseline + ${pharo-vm}/bin/pharo image/${bootstrap-image-name} eval --save "EpMonitor current disable. NonInteractiveTranscript stdout install. [ Metacello new repository: 'filetree://${src}'; baseline: '${baseline}'; onConflictUseLoaded; load ] ensure: [ EpMonitor current enable ]" + + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + + # assemble + ${pharo-vm}/bin/pharo image/${bootstrap-image-name} save "${pname}" + + mkdir dist + mv image/${pname}.* dist/ + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r ${pharo-vm}/bin $out + cp -r ${pharo-vm}/lib $out + cp -r dist/* $out/ + cp image/*.sources $out/ + mkdir $out/share + pushd ${src} + ${pkgs.zip}/bin/zip -r $out/share/src.zip . + popd + + runHook postInstall + ''; + + meta = { + longDescription = '' + NeoJSON is an elegant and efficient standalone Smalltalk framework to read and write JSON converting to or from Smalltalk objects. + ''; + inherit description homepage license maintainers; + mainProgram = "pharo"; + platforms = pkgs.lib.platforms.linux; + }; + }); + in rec { + defaultPackage = packages.default; + devShells = rec { + default = svenvc-neojson-12; + svenvc-neojson-12 = shared.devShell-for { + package = packages.svenvc-neojson-12; + inherit org pkgs repo tag; + nixpkgs-release = nixpkgsRelease; + }; + }; + packages = rec { + default = svenvc-neojson-12; + svenvc-neojson-12 = svenvc-neojson-for rec { + bootstrap-image-url = pharo-vm-12.resources.${system}.bootstrap-image-url; + bootstrap-image-sha256 = pharo-vm-12.resources.${system}.bootstrap-image-sha256; + bootstrap-image-name = pharo-vm-12.resources.${system}.bootstrap-image-name; + pharo-vm = pharo-vm-12.packages.${system}.pharo-vm; + }; + }; + }); +} diff --git a/.nix/shared.nix b/.nix/shared.nix new file mode 100644 index 0000000..a9e8b21 --- /dev/null +++ b/.nix/shared.nix @@ -0,0 +1,35 @@ +# .nix/shared.nix +# +# This file provides functions used by NeoJSON's Nix flake. +# +# MIT License +# +# Copyright (C) 2012 Sven Van Caekenberghe +# +# 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: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# 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. +rec { + shellHook-for = { nixpkgs-release, org, package, repo, tag }: + '' + export PS1="\033[37m[\[\033[01;34m\]${org}/${repo}\033[01;37m|\033[01;33m${tag}[\033[00m\] " + echo -e "\033[36m▗▖  ▗▖▗▞▀▚▖ ▄▄▄ \033[31m ▗▖ ▗▄▄▖ ▗▄▖ ▗▖  ▗▖ \033[32mhttps://github.com/${org}\033[0m" + echo -e "\033[36m▐▛▚▖▐▌▐▛▀▀▘█   █\033[31m ▐▌▐▌   ▐▌ ▐▌▐▛▚▖▐▌ \033[33mhttps://github.com/${org}/${repo}:${tag}\033[0m" + echo -e "\033[36m▐▌ ▝▜▌▝▚▄▄▖▀▄▄▄▀\033[31m ▐▌ ▝▀▚▖▐▌ ▐▌▐▌ ▝▜▌ \033[34mhttps://pharo.org\033[0m" + echo -e "\033[36m▐▌  ▐▌ \033[0m       \033[31m▗▄▄▞▘▗▄▄▞▘▝▚▄▞▘▐▌  ▐▌ \033[35mhttps://github.com/nixos/nixpkgs/tree/${nixpkgs-release}\033[0m" + echo + echo -e "Thank you for using \033[32m${package.pname}\033[0m \033[33m${package.version}\033[0m \033[31m(${org}/${repo}-${tag})\033[0m and for your appreciation of Smalltalk." + ''; + devShell-for = { nixpkgs-release, org, package, pkgs, repo, tag}: + pkgs.mkShell { + shellHook = shellHook-for { + inherit nixpkgs-release org package repo tag; + }; + }; + app-for = { package, entrypoint }: { + type = "app"; + program = "${package}/bin/${entrypoint}.sh"; + }; +} diff --git a/.project b/.project new file mode 100644 index 0000000..46c7795 --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory' : 'repository' +} \ No newline at end of file diff --git a/.smalltalk.ston b/.smalltalk.ston new file mode 100644 index 0000000..790a06b --- /dev/null +++ b/.smalltalk.ston @@ -0,0 +1,10 @@ +SmalltalkCISpec { + #loading : [ + SCIMetacelloLoadSpec { + #baseline : 'NeoJSON', + #directory : 'filetree', + #load : [ 'Core', 'Tests' ], + #platforms : [ #gemstone ] + } + ] +} diff --git a/.smalltalk_gemstone.ston b/.smalltalk_gemstone.ston new file mode 100644 index 0000000..790a06b --- /dev/null +++ b/.smalltalk_gemstone.ston @@ -0,0 +1,10 @@ +SmalltalkCISpec { + #loading : [ + SCIMetacelloLoadSpec { + #baseline : 'NeoJSON', + #directory : 'filetree', + #load : [ 'Core', 'Tests' ], + #platforms : [ #gemstone ] + } + ] +} diff --git a/.smalltalk_pharo.ston b/.smalltalk_pharo.ston new file mode 100644 index 0000000..65d9618 --- /dev/null +++ b/.smalltalk_pharo.ston @@ -0,0 +1,9 @@ +SmalltalkCISpec { + #loading : [ + SCIMetacelloLoadSpec { + #baseline : 'NeoJSON', + #directory : 'repository', + #platforms : [ #pharo ] + } + ] +} diff --git a/.smalltalkci/.unit-tests.ston b/.smalltalkci/.unit-tests.ston new file mode 100644 index 0000000..c5b9853 --- /dev/null +++ b/.smalltalkci/.unit-tests.ston @@ -0,0 +1,16 @@ +SmalltalkCISpec { + #loading : [ + SCIMetacelloLoadSpec { + #baseline : 'NeoJSON', + #directory : '../repository', + #load : [ 'build' ], + #platforms : [ #pharo ] + } + ], + #testing : { + #coverage : { + #packages : [ 'Neo-JSON*' ], + #format: #lcov + } + } +} diff --git a/README.md b/README.md index 3d12f0f..96bca58 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,31 @@ -NeoJSON [![Build Status](https://travis-ci.org/GsDevKit/NeoJSON.svg?branch=gs_master)](https://travis-ci.org/GsDevKit/NeoJSON) -======= +# NeoJSON NeoJSON is an elegant and efficient standalone Smalltalk framework to read and write JSON converting to or from Smalltalk objects. +[![CI](https://github.com/svenvc/NeoJSON/actions/workflows/CI.yml/badge.svg)](https://github.com/svenvc/NeoJSON/actions/workflows/CI.yml) + MIT Licensed. +A chapter in the [Enterprise Pharo](https://books.pharo.org/enterprise-pharo/) book is a good introduction to [NeoJSON](https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/NeoJSON/NeoJSON.html). + Go ahead and read the [NeoJSON paper](https://github.com/svenvc/docs/blob/master/neo/neo-json-paper.md). +Basically, NeoJSONWriter is used to write a JSON representation of Smalltalk objects to a textual stream. +Similary, NeoJSONReader is used to parse a JSON representation from a textual stream into Smalltalk objects. + +http://www.json.org +https://en.wikipedia.org/wiki/JSON + +## Pharo Installation + +You can load NeoJSON using Metacello + +```Smalltalk +Metacello new + repository: 'github://svenvc/NeoJSON/repository'; + baseline: 'NeoJSON'; + load. +``` ## GemStone Installation ```Smalltalk @@ -21,3 +40,9 @@ Metacello new repository: 'github://GsDevKit/NeoJSON:gs_master/repository'; load. ``` + +You can use the following dependency from your own Metacello configuration or baseline + +```Smalltalk +spec baseline: 'NeoJSON' with: [ spec repository: 'github://svenvc/NeoJSON/repository' ]. +``` diff --git a/filetree/.filetree b/filetree/.filetree new file mode 100644 index 0000000..6535e4d --- /dev/null +++ b/filetree/.filetree @@ -0,0 +1,3 @@ +{ + "packageExtension" : ".package", + "Metadata" : "false" } diff --git a/repository/BaselineOfNeoJSON.package/.filetree b/filetree/BaselineOfNeoJSON.package/.filetree similarity index 100% rename from repository/BaselineOfNeoJSON.package/.filetree rename to filetree/BaselineOfNeoJSON.package/.filetree diff --git a/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/README.md b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/README.md new file mode 100644 index 0000000..628fec7 --- /dev/null +++ b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/README.md @@ -0,0 +1,2 @@ +I am BaselineOfNeoJSON, I load the code for the NeoJSON project. +I am a BaselineOf. \ No newline at end of file diff --git a/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st new file mode 100644 index 0000000..82257eb --- /dev/null +++ b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st @@ -0,0 +1,29 @@ +baselines +baseline: spec + + spec + for: #common + do: [ spec + package: 'Neo-JSON-Core'; + package: 'Neo-JSON-Tests' with: [ spec requires: #('Neo-JSON-Core') ]; + group: 'default' with: #('Core' 'Tests'); + group: 'Core' with: #('Neo-JSON-Core'); + group: 'Tests' with: #('Neo-JSON-Tests') ]. + spec + for: #pharo + do: [ spec + package: 'Neo-JSON-Pharo-Core' with: [ spec requires: #('Neo-JSON-Core') ]; + package: 'Neo-JSON-Pharo-Tests' with: [ spec requires: #('Neo-JSON-Tests') ]; + package: 'Neo-JSON-Pharo-Examples' with: [ spec requires: #('Neo-JSON-Core') ]; + group: 'Core' with: #('Neo-JSON-Core' 'Neo-JSON-Pharo-Core'); + group: 'Tests' with: #('Neo-JSON-Tests' 'Neo-JSON-Pharo-Tests'); + group: 'Examples' with: #('Neo-JSON-Pharo-Examples') ]. + spec + for: #gemstone + do: [ spec + package: 'Neo-JSON-GemStone-Core' with: [ spec requires: #('Neo-JSON-Core') ]; + package: 'Neo-JSON-GemStone-Tests' with: [ spec requires: #('Neo-JSON-Tests') ]; + package: 'Neo-JSON-GemStone-Examples' with: [ spec requires: #('Neo-JSON-Core') ]; + group: 'Core' with: #('Neo-JSON-Core' 'Neo-JSON-GemStone-Core'); + group: 'Tests' with: #('Neo-JSON-Tests' 'Neo-JSON-GemStone-Tests'); + group: 'Examples' with: #('Neo-JSON-GemStone-Examples') ]. \ No newline at end of file diff --git a/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/properties.json b/filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/properties.json similarity index 100% rename from repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/properties.json rename to filetree/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/properties.json diff --git a/filetree/BaselineOfNeoJSON.package/properties.json b/filetree/BaselineOfNeoJSON.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/BaselineOfNeoJSON.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/.filetree b/filetree/Neo-JSON-Core.package/.filetree similarity index 100% rename from repository/ConfigurationOfNeoJSON.package/.filetree rename to filetree/Neo-JSON-Core.package/.filetree diff --git a/repository/Neo-JSON-Core.package/Boolean.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/Boolean.extension/instance/neoJsonOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/Boolean.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/Boolean.extension/instance/neoJsonOn..st diff --git a/repository/Neo-JSON-Core.package/Boolean.extension/properties.json b/filetree/Neo-JSON-Core.package/Boolean.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/Boolean.extension/properties.json rename to filetree/Neo-JSON-Core.package/Boolean.extension/properties.json diff --git a/repository/Neo-JSON-Core.package/Collection.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/Collection.extension/instance/neoJsonOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/Collection.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/Collection.extension/instance/neoJsonOn..st diff --git a/repository/Neo-JSON-Core.package/Collection.extension/properties.json b/filetree/Neo-JSON-Core.package/Collection.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/Collection.extension/properties.json rename to filetree/Neo-JSON-Core.package/Collection.extension/properties.json diff --git a/filetree/Neo-JSON-Core.package/Dictionary.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/Dictionary.extension/instance/neoJsonOn..st new file mode 100644 index 0000000..69834bb --- /dev/null +++ b/filetree/Neo-JSON-Core.package/Dictionary.extension/instance/neoJsonOn..st @@ -0,0 +1,4 @@ +*neo-json-core +neoJsonOn: neoJSONWriter + neoJSONWriter writeMap: self + diff --git a/repository/Neo-JSON-Core.package/Dictionary.extension/properties.json b/filetree/Neo-JSON-Core.package/Dictionary.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/Dictionary.extension/properties.json rename to filetree/Neo-JSON-Core.package/Dictionary.extension/properties.json diff --git a/repository/Neo-JSON-Core.package/Integer.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/Integer.extension/instance/neoJsonOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/Integer.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/Integer.extension/instance/neoJsonOn..st diff --git a/repository/Neo-JSON-Core.package/Integer.extension/properties.json b/filetree/Neo-JSON-Core.package/Integer.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/Integer.extension/properties.json rename to filetree/Neo-JSON-Core.package/Integer.extension/properties.json diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/README.md new file mode 100644 index 0000000..4f3b4a9 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/README.md @@ -0,0 +1,9 @@ +I am NeoJSONArray. +I am an Array. + +I am often used in combination with NeoJSONObject, to represent the result of parsing JSON. + + I support path access for nested instances of me, using #atPath: and #atPath:put: + +Used in its generic way, NeoJSONParser will return Arrays and Dictionaries. +Returning NeoJSONArrays and NeoJSONObjects, simple subclasses, allows to add some convenience methods. diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/class/exampleNumbers.st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/class/exampleNumbers.st new file mode 100644 index 0000000..550e964 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/class/exampleNumbers.st @@ -0,0 +1,19 @@ +example +exampleNumbers + + | numbers | + numbers := self new: 128 withAll: nil. + 0 to: 127 do: [ :n | + numbers + at: n + 1 + put: (NeoJSONObject new + integer: n; + decimal: (n printStringBase: 10); + octal: (n printStringBase: 8); + hexadecimal: (n printStringBase: 16); + binary: (n printStringBase: 2); + roman: n printStringRoman; + words: n asWords; + prime: n isPrime; + character: n asCharacter asString) ]. + ^ numbers \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/class/exampleSimple.st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/class/exampleSimple.st new file mode 100644 index 0000000..59bce1f --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/class/exampleSimple.st @@ -0,0 +1,4 @@ +example +exampleSimple + + ^ self withAll: { 0 . 1 . Float pi. 'string' . true . false. nil } \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/asString.st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/asString.st new file mode 100644 index 0000000..0fe9c6d --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/asString.st @@ -0,0 +1,4 @@ +print +asString + + ^self printString diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/at.add..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/at.add..st new file mode 100644 index 0000000..3a4aa36 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/at.add..st @@ -0,0 +1,5 @@ +adding +at: index add: object + ^ index = #'-' + ifTrue: [ self addLast: object ] + ifFalse: [ self add: object before: index ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath..st new file mode 100644 index 0000000..8086f62 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath..st @@ -0,0 +1,10 @@ +accessing +atPath: keyCollection + "Use each key in keyCollection recursively, return nil when a key is missing. + Note how keys can also be indexes to arrays." + + | value | + value := self. + keyCollection do: [ :each | + value := value at: each ifAbsent: [ ^ nil ] ]. + ^ value \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath.add..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath.add..st new file mode 100644 index 0000000..96a6ec9 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath.add..st @@ -0,0 +1,14 @@ +adding +atPath: keyCollection add: newValue + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays. + This variant will insert/add to arrays" + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each add: target species new ] ]. + ^ target at: keyCollection last add: newValue \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath.put..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath.put..st new file mode 100644 index 0000000..13f29de --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/atPath.put..st @@ -0,0 +1,13 @@ +accessing +atPath: keyCollection put: newValue + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each put: target species new ] ]. + ^ target at: keyCollection last put: newValue \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/findPath..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/findPath..st new file mode 100644 index 0000000..180b1b8 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/findPath..st @@ -0,0 +1,12 @@ +accessing +findPath: conditionBlock + "Find and return the first path to an object in the graph that I represent + for which conditionBlock holds. Return nil when not found." + + (conditionBlock value: self) ifTrue: [ ^ #(()) ]. + self doWithIndex: [ :value :index | + (conditionBlock value: value) ifTrue: [ ^ { index } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPath: conditionBlock) ifNotNil: [ :subPath | + ^ { index } , subPath ] ] ]. + ^ nil \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/findPaths..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/findPaths..st new file mode 100644 index 0000000..48598fb --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/findPaths..st @@ -0,0 +1,13 @@ +accessing +findPaths: conditionBlock + "Find and return all paths to objects in the graph that I represent + for which conditionBlock holds. Return an empty collection when none are found." + + | found | + found := OrderedCollection new. + self doWithIndex: [ :value :index | + (conditionBlock value: value) ifTrue: [ found add: { index } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPaths: conditionBlock) do: [ :subPath | + found add: { index } , subPath ] ] ]. + ^ found \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/printOn..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/printOn..st new file mode 100644 index 0000000..5f56606 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/printOn..st @@ -0,0 +1,10 @@ +print +printOn: stream + "I use my JSON representation when printing myself" + + [ (NeoJSONWriter on: stream) nextPut: self ] + on: Error + do: [ :exception | + stream + nextPutAll: ' Error printing JSON: '; + print: exception ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/removeKey..st b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/removeKey..st new file mode 100644 index 0000000..41021d1 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/instance/removeKey..st @@ -0,0 +1,5 @@ +removing +removeKey: index + "Polymorphic with NeoJSONObject: remove the element at index" + + ^ self removeAt: index \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONArray.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/properties.json new file mode 100644 index 0000000..043cb0d --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONArray.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Core", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONArray", + "pools" : [ + ], + "super" : "OrderedCollection", + "type" : "normal" } diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/README.md diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/decoder..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/decoder..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/decoder..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/decoder..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/encoder..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/encoder..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/encoder..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/encoder..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/identifier.st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/identifier.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/identifier.st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/identifier.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfElementSchema..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfElementSchema..st similarity index 53% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfElementSchema..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfElementSchema..st index ef97855..97c02ab 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfElementSchema..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfElementSchema..st @@ -1,11 +1,15 @@ mapping listOfElementSchema: elementSchema "Set the reader to a block that will create an instance of the - standard listClass while reading a list of elements of type elementSchema" + standard listClass while reading a list of elements of type elementSchema. + Pass down the elementSchema to the elements in the writer." self reader: [ :jsonReader | jsonReader listClass streamContents: [ :stream | jsonReader parseListDo: [ | element | element := jsonReader nextAs: elementSchema. - stream nextPut: element ] ] ] - "we do not set a writer, #neoJsonOn: should be sufficient" \ No newline at end of file + stream nextPut: element ] ] ]. + self writer: [ :jsonWriter :list | + jsonWriter writeListStreamingDo: [ :listWriter | + list do: [ :each | + listWriter writeElement: each as: elementSchema ] ] ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType..st new file mode 100644 index 0000000..bdc43572 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType..st @@ -0,0 +1,15 @@ +mapping +listOfType: collectionClass + "Set the reader to a block that will create an instance of collectionClass + using #streamContents: while reading a list of elements. + Set the writer to write the list's elements." + + self reader: [ :jsonReader | + collectionClass streamContents: [ :stream | + jsonReader parseListDo: [ | element | + element := jsonReader next. + stream nextPut: element ] ] ]. + self writer: [ :jsonWriter :list | + jsonWriter writeListStreamingDo: [ :listWriter | + list do: [ :each | + listWriter writeElement: each ] ] ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType.andElementSchema..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType.andElementSchema..st similarity index 55% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType.andElementSchema..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType.andElementSchema..st index 4377070..fa7bcbf 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType.andElementSchema..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType.andElementSchema..st @@ -1,11 +1,15 @@ mapping listOfType: collectionClass andElementSchema: elementSchema - "Set the reader to a block that will create an instance of collectionClass - using #streamContents: while reading a list of elements of type elementSchema" + "Set the reader to a block that will create an instance of collectionClass + using #streamContents: while reading a list of elements of type elementSchema. + Pass down the elementSchema to the elements in the writer." self reader: [ :jsonReader | collectionClass streamContents: [ :stream | jsonReader parseListDo: [ | element | element := jsonReader nextAs: elementSchema. - stream nextPut: element ] ] ] - "we do not set a writer, #neoJsonOn: should be sufficient" \ No newline at end of file + stream nextPut: element ] ] ]. + self writer: [ :jsonWriter :list | + jsonWriter writeListStreamingDo: [ :listWriter | + list do: [ :each | + listWriter writeElement: each as: elementSchema ] ] ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/mapWithValueSchema..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/mapWithValueSchema..st similarity index 66% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/mapWithValueSchema..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/mapWithValueSchema..st index 7d8aa88..ec3d3c0 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/mapWithValueSchema..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/mapWithValueSchema..st @@ -9,5 +9,8 @@ mapWithValueSchema: valueSchema jsonReader parseMapKeysDo: [ :key | | value | value := jsonReader nextAs: valueSchema. map at: key put: value ]. - map ] - "we do not set a writer, #neoJsonOn: should be sufficient" \ No newline at end of file + map ]. + self writer: [ :jsonWriter :map | + jsonWriter writeMapStreamingDo: [ :mapWriter | + map keysAndValuesDo: [ :key :value | + mapWriter writeKey: key value: value as: valueSchema ] ] ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/readFrom..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/readFrom..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/readFrom..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/readFrom..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/reader..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/reader..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/reader..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/reader..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/schemaName..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/schemaName..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/schemaName..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/schemaName..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writeObject.on..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writeObject.on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writeObject.on..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writeObject.on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writer..st b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writer..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writer..st rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/writer..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/properties.json similarity index 87% rename from repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/properties.json index c9d3ad2..2619891 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONCustomMapping.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "schemaName", "reader", diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/README.md new file mode 100644 index 0000000..8f28ba8 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/README.md @@ -0,0 +1,22 @@ +I am NeoJSONFloatPrinter. + +I print Float numbers in a compact, human friendly format. + +The following (default) parameters are used: + - base 10 - hardcoded (for now) + - precision 5 digits + - decimal point - hardcoded (for now) + - exponent e - hardcoded (for now) + - NaN, Inf and -Inf - hardcoded (for now) + - lower 1e-4 + - upper 1e6 + - decimal notation for abs values inside abs [ lower, upper ] + - scientific notation for abs values outside [ lower, upper ] + - no padding, no trailing zeros in fraction part + - only negative sign, never a positive sign + - no thousands separators + - no engineering notation + +See my class side for configuration examples. + +My public interface is in the printing protocol. diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/class/lowPrecision.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/class/lowPrecision.st new file mode 100644 index 0000000..323ab85 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/class/lowPrecision.st @@ -0,0 +1,7 @@ +instance creation +lowPrecision + ^ self new + precision: 2; + lower: 1e-2; + upper: 1e5; + yourself \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/class/scientificOnly.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/class/scientificOnly.st new file mode 100644 index 0000000..ba5a518 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/class/scientificOnly.st @@ -0,0 +1,6 @@ +instance creation +scientificOnly + ^ self new + lower: 0; + upper: 0; + yourself \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/decimalPoint.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/decimalPoint.st new file mode 100644 index 0000000..294c6e6 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/decimalPoint.st @@ -0,0 +1,3 @@ +constants +decimalPoint + ^ $. \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/exponent.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/exponent.st new file mode 100644 index 0000000..e397b57 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/exponent.st @@ -0,0 +1,3 @@ +constants +exponent + ^ $e \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/infinite.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/infinite.st new file mode 100644 index 0000000..0d23af7 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/infinite.st @@ -0,0 +1,3 @@ +constants +infinite + ^ 'Inf' \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/initialize.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/initialize.st new file mode 100644 index 0000000..d808a27 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/initialize.st @@ -0,0 +1,7 @@ +initialize-release +initialize + super initialize. + base := 10. + precision := 5. + lower := 1e-4. + upper := 1e6 \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/lower..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/lower..st new file mode 100644 index 0000000..e582521 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/lower..st @@ -0,0 +1,3 @@ +initialize-release +lower: number + lower := number \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/nan.st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/nan.st new file mode 100644 index 0000000..a394bc5 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/nan.st @@ -0,0 +1,3 @@ +constants +nan + ^ 'NaN' \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/precision..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/precision..st new file mode 100644 index 0000000..86df656 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/precision..st @@ -0,0 +1,4 @@ +initialize-release +precision: numberOfDigits + self assert: (numberOfDigits between: 1 and: 20). + precision := numberOfDigits \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print..st new file mode 100644 index 0000000..941c608 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print..st @@ -0,0 +1,4 @@ +printing +print: float + ^ String new: 16 streamContents: [ :out | + self print: float on: out ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.decimalOn..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.decimalOn..st new file mode 100644 index 0000000..ddba67a --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.decimalOn..st @@ -0,0 +1,7 @@ +private +print: float decimalOn: stream + stream print: float asInteger. + stream nextPut: self decimalPoint. + self + print: (float fractionPart * (base raisedTo: precision)) rounded + fractionOn: stream \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.fractionOn..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.fractionOn..st new file mode 100644 index 0000000..3926781 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.fractionOn..st @@ -0,0 +1,13 @@ +private +print: fractionPart fractionOn: stream + | zeros | + zeros := 0. "leading zeros are significant, trailing zeros are not printed" + precision to: 1 by: -1 do: [ :position | | digit | + digit := fractionPart digitAt: position base: base. + digit = 0 + ifTrue: [ zeros := zeros +1 ] + ifFalse: [ + zeros > 0 ifTrue: [ + zeros timesRepeat: [ stream nextPut: $0 ]. + zeros := 0 ]. + stream nextPut: digit asCharacterDigit ] ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.on..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.on..st new file mode 100644 index 0000000..e8def3e --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.on..st @@ -0,0 +1,12 @@ +printing +print: float on: stream + | int abs | + (float isZero or: [ float isFinite not ]) + ifTrue: [ ^ self print: float specialOn: stream ]. + self print: float signOn: stream. + ((abs := float abs) between: lower and: upper) + ifTrue: [ + (int := abs asInteger) = abs + ifTrue: [ int printOn: stream ] + ifFalse: [ self print: abs decimalOn: stream ] ] + ifFalse: [ self print: abs scientificOn: stream ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.scientificOn..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.scientificOn..st new file mode 100644 index 0000000..75a6e90 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.scientificOn..st @@ -0,0 +1,9 @@ +private +print: float scientificOn: stream + | exponent mantissa | + exponent := (float ln / base ln) floor. + mantissa := float / (base raisedTo: exponent). + self print: mantissa decimalOn: stream. + stream + nextPut: self exponent; + print: exponent \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.signOn..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.signOn..st new file mode 100644 index 0000000..c0157e1 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.signOn..st @@ -0,0 +1,4 @@ +private +print: float signOn: stream + float sign = -1 + ifTrue: [ stream nextPut: $- ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.specialOn..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.specialOn..st new file mode 100644 index 0000000..c29fe45 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/print.specialOn..st @@ -0,0 +1,12 @@ +private +print: float specialOn: stream + float isZero + ifTrue: [ + stream nextPut: $0 ] + ifFalse: [ + float isNaN + ifTrue: [ + stream nextPutAll: self nan ] + ifFalse: [ + self print: float signOn: stream. + stream nextPutAll: self infinite ] ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/printFloat.on..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/printFloat.on..st new file mode 100644 index 0000000..35d1b88 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/printFloat.on..st @@ -0,0 +1,3 @@ +printing +printFloat: float on: stream + self print: float on: stream \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/upper..st b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/upper..st new file mode 100644 index 0000000..6b83f8b --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/instance/upper..st @@ -0,0 +1,3 @@ +initialize-release +upper: number + upper := number \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/properties.json new file mode 100644 index 0000000..b4dda76 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONFloatPrinter.class/properties.json @@ -0,0 +1,17 @@ +{ + "category" : "Neo-JSON-Core", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "precision", + "lower", + "upper", + "base" ], + "name" : "NeoJSONFloatPrinter", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/README.md diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/customMappingFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/customMappingFor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/customMappingFor..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/customMappingFor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.customDo..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.customDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.customDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.customDo..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.do..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.do..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.do..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/for.do..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapAllInstVarsFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapAllInstVarsFor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapAllInstVarsFor..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapAllInstVarsFor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapInstVarsFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapInstVarsFor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapInstVarsFor..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mapInstVarsFor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor.ifAbsent..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor.ifAbsent..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor.ifAbsent..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappingFor.ifAbsent..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappings.st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappings.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappings.st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/mappings.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/objectMappingFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/objectMappingFor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/objectMappingFor..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/objectMappingFor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/resolveMappingFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/resolveMappingFor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/instance/resolveMappingFor..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/instance/resolveMappingFor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/properties.json similarity index 85% rename from repository/Neo-JSON-Core.package/NeoJSONMapper.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONMapper.class/properties.json index d2d448a..921cb67 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONMapper.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "mappings" ], "name" : "NeoJSONMapper", diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapping.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONMapping.class/README.md diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/identifier.st b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/identifier.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/identifier.st rename to filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/identifier.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/printOn..st b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/printOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/printOn..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/printOn..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/readFrom..st b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/readFrom..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/readFrom..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/readFrom..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/writeObject.on..st b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/writeObject.on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONMapping.class/instance/writeObject.on..st rename to filetree/Neo-JSON-Core.package/NeoJSONMapping.class/instance/writeObject.on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/properties.json similarity index 77% rename from repository/Neo-JSON-Core.package/NeoJSONMapping.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONMapping.class/properties.json index 9c8edce..3463234 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONMapping.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 3/23/2014 19:22", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONMapping", diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/README.md new file mode 100644 index 0000000..5ce2759 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/README.md @@ -0,0 +1,3 @@ +I am NeoJSONMappingNotFound. I am signalled when no mapping is found for a schema. + +Portability comment: In Pharo, I could technically subclass from NotFound directly, avoid all my defined methods and only keep #messageText and #standardMessageText. However, NotFound exception does not exist in other dialects. To keep NeoJSON as portable as possible we duplicate some Pharo code into myself. \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor..st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor..st new file mode 100644 index 0000000..9c1dc48 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor..st @@ -0,0 +1,7 @@ +instance creation +signalFor: anObject + "Create and signal an exception for anObject in the default receiver." + + ^ self new + object: anObject; + signal \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor.in..st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor.in..st similarity index 53% rename from repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor.in..st rename to filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor.in..st index 2679f96..e016a6a 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor.in..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/class/signalFor.in..st @@ -1,6 +1,6 @@ -as yet unclassified +instance creation signalFor: anObject in: aCollection - "Create and signal a NotFound exception for anObject in aCollection." + "Create and signal an exception for anObject in aCollection." ^ self new object: anObject; diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection..st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection..st new file mode 100644 index 0000000..6d3b25c --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection..st @@ -0,0 +1,5 @@ +accessing +collection: aCollection + "Set the collection where something is not found in" + + collection := aCollection diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection.st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection.st new file mode 100644 index 0000000..28f4b12 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection.st @@ -0,0 +1,5 @@ +accessing +collection + "Return the collection where something is not found in" + + ^ collection diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/messageText.st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/messageText.st new file mode 100644 index 0000000..f43900d --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/messageText.st @@ -0,0 +1,5 @@ +accessing +messageText + "Overwritten with standard text. To ease portability to other Smalltalk dialects we do not access the instVar 'messageText' as not all dialects have it. Not caching the value on the instVar shouldn't bring any performance hit in this case. " + + ^ self standardMessageText diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object..st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object..st new file mode 100644 index 0000000..3eaf438 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object..st @@ -0,0 +1,5 @@ +accessing +object: anObject + "Set the object that was not found" + + object := anObject diff --git a/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object.st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object.st new file mode 100644 index 0000000..bdef075 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object.st @@ -0,0 +1,5 @@ +accessing +object + "Return the object that was not found" + + ^ object diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/standardMessageText.st b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/standardMessageText.st similarity index 95% rename from repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/standardMessageText.st rename to filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/standardMessageText.st index a4cce37..182f3fe 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/standardMessageText.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/standardMessageText.st @@ -1,4 +1,4 @@ -printing +private standardMessageText ^ String streamContents: [ :stream | stream << 'No mapping found for '. diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/properties.json similarity index 80% rename from repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/properties.json index 93f6d5f..a32a862 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/properties.json @@ -4,10 +4,10 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "object", - "signaler" ], + "collection" ], "name" : "NeoJSONMappingNotFound", "pools" : [ ], diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/README.md new file mode 100644 index 0000000..77bd663 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/README.md @@ -0,0 +1,39 @@ +I am NeoJSONObject. +I am an OrderedDictionary. + +I behave more like a JavaScript object. I return nil for missing keys. I allow any property to be read or set by using a normal accessor message. + +The following are equivalent: + + self foo. + self at: #foo. + +As are the following + + self foo: 1. + self at: #foo put: 1. + +Except that in the first case, self is returned. + +I can optionally be used by NeoJSONReader as mapClass (see #mapClass:). + +For output, I act just like my superclass (it is thus not necessary to do any conversions). + +Example: + + NeoJSONObject fromString: '{"foo":1,"bar":-2}'. + NeoJSONObject new foo: 1; bar: -2. + { #x -> 100. #y -> 200 } as: NeoJSONObject. + (NeoJSONObject new data: (NeoJSONObject new id: #sensor1; value: 37.5)) asString. + +I use JSON as my printed representation. To convert me to JSON, use #printString or #asString. + +Additionally, I support path access for nested instances of me, using #atPath: and #atPath:put: + +The first is special because it returns nil as soon as a key is missing. The second is special because it creates extra levels (instances of me) as needed to follow the path of keys. + + NeoJSONObject new atPath: #(one two three) put: 42; yourself. + NeoJSONObject new atPath: #(one two three) put: 42; atPath: #(one two three). + +I am an Dictionary. The official JSON specification clearly states ""An object is an unordered set of name/value pairs"". +I work together with NeoJSONArray. \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinates.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinates.st new file mode 100644 index 0000000..dfc500a --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinates.st @@ -0,0 +1,6 @@ +example +exampleCoordinates + + ^ (0 to: 4) + collect: [ :each | self new x: each; y: each * 2 ] + as: NeoJSONArray \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinatesParsing.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinatesParsing.st new file mode 100644 index 0000000..ce56ec8 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinatesParsing.st @@ -0,0 +1,7 @@ +example +exampleCoordinatesParsing + + | result | + result := self fromString: NeoJSONReader exampleCoordinatesJSON. + self assert: result equals: self exampleCoordinates. + ^ result \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinatesWriting.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinatesWriting.st new file mode 100644 index 0000000..1036295 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleCoordinatesWriting.st @@ -0,0 +1,4 @@ +example +exampleCoordinatesWriting + + ^ self exampleCoordinates printString \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleMagnitudeClassHierarchy.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleMagnitudeClassHierarchy.st new file mode 100644 index 0000000..0bb804e --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleMagnitudeClassHierarchy.st @@ -0,0 +1,17 @@ +example +exampleMagnitudeClassHierarchy + + | builder | + builder := [ :aClass | + NeoJSONObject new + name: aClass name; + superclass: aClass superclass name; + instanceVariables: aClass instVarNames; + category: aClass category; + totalInstanceVariablesCount: aClass allInstVarNames size; + methodCount: aClass methods size; + totalMethodCount: aClass allMethods size; + subclasses: (aClass subclasses + collect: [ :aSubclass | builder value: aSubclass ] + as: NeoJSONArray) ]. + ^ builder value: Magnitude \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleNested.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleNested.st new file mode 100644 index 0000000..8e3b2d8 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleNested.st @@ -0,0 +1,4 @@ +example +exampleNested + + ^ self exampleSimple array: NeoJSONArray exampleSimple \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleNestedRoundtrip.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleNestedRoundtrip.st new file mode 100644 index 0000000..f784191 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleNestedRoundtrip.st @@ -0,0 +1,8 @@ +example +exampleNestedRoundtrip + + | json result| + json := self exampleNested printString. + result := self fromString: json. + self assert: result equals: self exampleNested. + ^ result \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimple.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimple.st new file mode 100644 index 0000000..979a5bc --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimple.st @@ -0,0 +1,6 @@ +example +exampleSimple + + ^ self new + foo: 100; + bar: 200 \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleJSON.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleJSON.st new file mode 100644 index 0000000..b957c13 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleJSON.st @@ -0,0 +1,4 @@ +example +exampleSimpleJSON + + ^ '{"foo":100,"bar":200}' \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleParsing.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleParsing.st new file mode 100644 index 0000000..7ea3e2a --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleParsing.st @@ -0,0 +1,7 @@ +example +exampleSimpleParsing + + | result | + result := self fromString: self exampleSimpleJSON. + self assert: result equals: self exampleSimple. + ^ result \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleUsage.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleUsage.st new file mode 100644 index 0000000..a42191e --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleUsage.st @@ -0,0 +1,10 @@ +example +exampleSimpleUsage + + | simple | + simple := NeoJSONObject exampleSimple. + self assert: simple foo equals: (simple at: #foo). + self assert: (simple foo: -1) equals: (simple at: #foo put: -1; yourself). + self assert: (simple includesKey: #baz) not. + self assert: simple baz equals: nil. + ^ simple \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleWriting.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleWriting.st new file mode 100644 index 0000000..397cbbd --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/exampleSimpleWriting.st @@ -0,0 +1,7 @@ +example +exampleSimpleWriting + + | result | + result := self exampleSimple printString. + self assert: result equals: self exampleSimpleJSON. + ^ result \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/fromStream..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/fromStream..st new file mode 100644 index 0000000..4a20817 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/fromStream..st @@ -0,0 +1,16 @@ +convenience +fromStream: readStream + "Parse stream as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + | jsonReader | + + jsonReader := Smalltalk globals isDictionary + ifTrue: [ "Pharo" + NeoJSONReader on: readStream readStream ] + ifFalse: [ "GemStone" + NeoJSONReader on: readStream ]. + + ^ jsonReader + mapClass: self; + listClass: NeoJSONArray; + propertyNamesAsSymbols: true; + next \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/fromString..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/fromString..st new file mode 100644 index 0000000..c9bfb95 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/fromString..st @@ -0,0 +1,5 @@ +convenience +fromString: string + "Parse string as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ self fromStream: string readStream \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/readFrom..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/readFrom..st new file mode 100644 index 0000000..a792130 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/class/readFrom..st @@ -0,0 +1,5 @@ +convenience +readFrom: readStream + "Parse stream as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ self fromStream: readStream \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at..st new file mode 100644 index 0000000..5ef6ca3 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at..st @@ -0,0 +1,6 @@ +accessing +at: key + "I return nil for missing keys. + My superclass would signal a KeyNotFound." + + ^ self at: key ifAbsent: [ nil ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.add..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.add..st new file mode 100644 index 0000000..f4609ff --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.add..st @@ -0,0 +1,3 @@ +add +at: key add: object + ^ self at: key put: object \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.at..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.at..st new file mode 100644 index 0000000..66f30e4 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.at..st @@ -0,0 +1,6 @@ +nested dictionaries +at: firstKey at: secondKey + "I return nil for missing keys. + My superclass would signal a KeyNotFound." + + ^ self atPath: { firstKey. secondKey } \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.at.put..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.at.put..st new file mode 100644 index 0000000..2520d3b --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.at.put..st @@ -0,0 +1,5 @@ +nested dictionaries +at: firstKey at: secondKey put: value + "Store value under secondKey in nested object under firstKey, create new level when needed" + + ^ self atPath: { firstKey. secondKey } put: value \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.ifPresent.ifAbsentPut..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.ifPresent.ifAbsentPut..st new file mode 100644 index 0000000..285b913 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/at.ifPresent.ifAbsentPut..st @@ -0,0 +1,13 @@ +accessing +at: key ifPresent: aPresentBlock ifAbsentPut: anAbsentBlock + "Lookup the given key in the receiver. If it is present, answer the + value of evaluating the first block optionally with the value associated with the key. + Otherwise store and return the result of evaluating the second block as the new value of the key." + + "Overwritten to patch a bug in the superclass implementation in Pharo 7 and 8. + This problem was fixed in Pharo 9 where this overwrite is no longer necessary but harmless." + + ^ self + at: key + ifPresent: aPresentBlock + ifAbsent: [ self at: key put: anAbsentBlock value ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath..st new file mode 100644 index 0000000..8086f62 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath..st @@ -0,0 +1,10 @@ +accessing +atPath: keyCollection + "Use each key in keyCollection recursively, return nil when a key is missing. + Note how keys can also be indexes to arrays." + + | value | + value := self. + keyCollection do: [ :each | + value := value at: each ifAbsent: [ ^ nil ] ]. + ^ value \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath.add..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath.add..st new file mode 100644 index 0000000..bfc0d88 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath.add..st @@ -0,0 +1,14 @@ +accessing +atPath: keyCollection add: newValue + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays. + This variant will insert/add to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each add: target species new ] ]. + ^ target at: keyCollection last add: newValue \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath.put..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath.put..st new file mode 100644 index 0000000..13f29de --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/atPath.put..st @@ -0,0 +1,13 @@ +accessing +atPath: keyCollection put: newValue + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each put: target species new ] ]. + ^ target at: keyCollection last put: newValue \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/doesNotUnderstand..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/doesNotUnderstand..st new file mode 100644 index 0000000..a805e42 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/doesNotUnderstand..st @@ -0,0 +1,12 @@ +reflective operations +doesNotUnderstand: message + "Overwritten so that 'self foo' becomes 'self at: #foo' + and 'self foo: 1' becomes 'self at: #foo put: 1' except that self is returned" + + | key | + key := message selector. + key isUnary + ifTrue: [ ^ self at: key ]. + ^ (key isKeyword and: [ key numArgs = 1 ]) + ifTrue: [ self at: key allButLast asSymbol put: message arguments first; yourself ] + ifFalse: [ super doesNotUnderstand: message ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/findPath..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/findPath..st new file mode 100644 index 0000000..87d2b48 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/findPath..st @@ -0,0 +1,12 @@ +accessing +findPath: conditionBlock + "Find and return the first path to an object in the graph that I represent + for which conditionBlock holds. Return nil when not found." + + (conditionBlock value: self) ifTrue: [ ^ #(()) ]. + self keysAndValuesDo: [ :key :value | + (conditionBlock value: value) ifTrue: [ ^ { key } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPath: conditionBlock) ifNotNil: [ :subPath | + ^ { key } , subPath ] ] ]. + ^ nil \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/findPaths..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/findPaths..st new file mode 100644 index 0000000..47fd80e --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/findPaths..st @@ -0,0 +1,13 @@ +accessing +findPaths: conditionBlock + "Find and return all paths to objects in the graph that I represent + for which conditionBlock holds. Return an empty collection when none are found." + + | found | + found := OrderedCollection new. + self keysAndValuesDo: [ :key :value | + (conditionBlock value: value) ifTrue: [ found add: { key } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPaths: conditionBlock) do: [ :subPath | + found add: { key } , subPath ] ] ]. + ^ found \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/name.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/name.st new file mode 100644 index 0000000..80a9a04 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/name.st @@ -0,0 +1,5 @@ +accessing +name + "Overwritten to make this accessor available as key" + + ^ self at: #name \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/printOn..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/printOn..st new file mode 100644 index 0000000..d5a197b --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/printOn..st @@ -0,0 +1,10 @@ +printing +printOn: stream + "I use my JSON representation when printing myself" + + [ (NeoJSONWriter on: stream) nextPut: self ] + on: Error + do: [ :exception | + stream + nextPutAll: ' Error printing JSON: '; + print: exception ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/removeAtPath..st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/removeAtPath..st new file mode 100644 index 0000000..3c216fe --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/removeAtPath..st @@ -0,0 +1,11 @@ +accessing +removeAtPath: keyCollection + "Use each key in keyCollection recursively and remove the final key. + Note how keys can also be indexes to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target at: each ifAbsent: [ ^ self ] ]. + ^ target removeKey: keyCollection last \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/value.st b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/value.st new file mode 100644 index 0000000..278cafa --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/instance/value.st @@ -0,0 +1,5 @@ +evaluating +value + "Overwritten to make this accessor available as key" + + ^ self at: #value \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObject.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/properties.json new file mode 100644 index 0000000..8e5e5e3 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObject.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Core", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONObject", + "pools" : [ + ], + "super" : "Dictionary", + "type" : "normal" } diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/README.md diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/allowNil.st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/allowNil.st new file mode 100644 index 0000000..58dca2b --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/allowNil.st @@ -0,0 +1,5 @@ +initialize-release +allowNil + "Set that I will allow nil/null values when I read/expect an object" + + allowNil := true \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/identifier.st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/identifier.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/identifier.st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/identifier.st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/initialize.st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/initialize.st new file mode 100644 index 0000000..074317d --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/initialize.st @@ -0,0 +1,5 @@ +initialize-release +initialize + super initialize. + properties := OrderedCollection new. + allowNil := false \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.mutator.to..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.mutator.to..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.mutator.to..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.mutator.to..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.to..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.to..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.to..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessor.to..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessors..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessors..st new file mode 100644 index 0000000..e9552cd --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessors..st @@ -0,0 +1,3 @@ +mapping +mapAccessors: accessors + ^ accessors collect: [ :each | self mapAccessor: each ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAllInstVars.st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAllInstVars.st new file mode 100644 index 0000000..740548c --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAllInstVars.st @@ -0,0 +1,3 @@ +convenience +mapAllInstVars + ^ self mapInstVars: subjectClass allInstVarNames \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar.to..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar.to..st new file mode 100644 index 0000000..36ee121 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar.to..st @@ -0,0 +1,15 @@ +mapping +mapInstVar: instVarName to: propertyName + | index | + index := + "For portability reasons, do not use instVarIndexFor:ifAbsent: + (it doesn't exist in all Smalltalk dialects) but the below approach. + Also, convert to symbols for portability reasons" + (subjectClass allInstVarNames collect: [ :each | each asSymbol ]) + indexOf: instVarName asSymbol + ifAbsent: [ self error: 'Inst var not found: ', instVarName printString ]. + ^ self + mapProperty: propertyName asString + getter: [ :object | object instVarAt: index ] + setter: [ :object :value | object instVarAt: index put: value ] + diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars..st new file mode 100644 index 0000000..240320e --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars..st @@ -0,0 +1,3 @@ +mapping +mapInstVars: instVarNames + ^ instVarNames collect: [ :each | self mapInstVar: each ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars.st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars.st new file mode 100644 index 0000000..c7296cb --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars.st @@ -0,0 +1,3 @@ +convenience +mapInstVars + ^ self mapInstVars: subjectClass instVarNames \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapProperty.getter.setter..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapProperty.getter.setter..st new file mode 100644 index 0000000..d797ec3 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapProperty.getter.setter..st @@ -0,0 +1,11 @@ +mapping +mapProperty: propertyName getter: readBlock setter: writeBlock + | propertyMapping | + propertyMapping := NeoJSONPropertyMapping new. + propertyMapping + propertyName: propertyName asSymbol; + getter: readBlock; + setter: writeBlock. + properties removeAllSuchThat: [ :each | each propertyName = propertyMapping propertyName ]. + properties addLast: propertyMapping. + ^ propertyMapping diff --git a/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/propertyNamed.ifAbsent..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/propertyNamed.ifAbsent..st new file mode 100644 index 0000000..975f27a --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/propertyNamed.ifAbsent..st @@ -0,0 +1,5 @@ +accessing +propertyNamed: propertyName ifAbsent: block + | symbolPropertyName | + symbolPropertyName := propertyName asSymbol. + ^ properties detect: [ :each | each propertyName = symbolPropertyName ] ifNone: block \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/readFrom..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/readFrom..st similarity index 71% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/readFrom..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/readFrom..st index 9c4fee9..b049157 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/readFrom..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/readFrom..st @@ -2,6 +2,9 @@ parsing readFrom: jsonReader | anObject | anObject := subjectClass new. + allowNil ifTrue: [ + jsonReader parseConstantDo: [ :value | + ^ value ifNotNil: [ jsonReader error: 'Unexpected boolean constant' ] ] ]. jsonReader parseMapKeysDo: [ :key | (self propertyNamed: key ifAbsent: [self propertyNamed: key asSymbol ifAbsent:[nil] ]) ifNil: [ diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/subjectClass..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/subjectClass..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/subjectClass..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/subjectClass..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/writeObject.on..st b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/writeObject.on..st similarity index 81% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/writeObject.on..st rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/writeObject.on..st index c733ca3..96857d6 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/writeObject.on..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/writeObject.on..st @@ -1,5 +1,5 @@ writing writeObject: anObject on: jsonWriter jsonWriter writeMapStreamingDo: [ :jsonMapWriter | - properties valuesDo: [ :each | + properties do: [ :each | each writeObject: anObject on: jsonMapWriter ] ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/properties.json similarity index 80% rename from repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/properties.json index 8f3cf92..706022a 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONObjectMapping.class/properties.json @@ -4,10 +4,11 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "subjectClass", - "properties" ], + "properties", + "allowNil" ], "name" : "NeoJSONObjectMapping", "pools" : [ ], diff --git a/repository/Neo-JSON-Core.package/NeoJSONParseError.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONParseError.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONParseError.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONParseError.class/README.md diff --git a/repository/Neo-JSON-Core.package/NeoJSONParseError.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONParseError.class/properties.json similarity index 85% rename from repository/Neo-JSON-Core.package/NeoJSONParseError.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONParseError.class/properties.json index 08bfd8d..2d89d8c 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONParseError.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONParseError.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONParseError", diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/README.md diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/getter..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/getter..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/getter..st rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/getter..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/printOn..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/printOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/printOn..st rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/printOn..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName..st new file mode 100644 index 0000000..7b044f7 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName..st @@ -0,0 +1,3 @@ +accessing +propertyName: symbolOrString + propertyName := symbolOrString asSymbol \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName.st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName.st new file mode 100644 index 0000000..2a727f6 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName.st @@ -0,0 +1,3 @@ +accessing +propertyName + ^ propertyName \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/readObject.from..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/readObject.from..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/readObject.from..st rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/readObject.from..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/setter..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/setter..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/setter..st rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/setter..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/valueSchema..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/valueSchema..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/valueSchema..st rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/valueSchema..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/writeObject.on..st b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/writeObject.on..st new file mode 100644 index 0000000..b3b0f51 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/writeObject.on..st @@ -0,0 +1,6 @@ +writing +writeObject: anObject on: jsonMapWriter + | value | + value := getter value: anObject. + (value notNil or: [ jsonMapWriter writeNil ]) + ifTrue: [ jsonMapWriter writeKey: propertyName value: value as: valueSchema ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/properties.json similarity index 88% rename from repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/properties.json index 6af8544..1c73c65 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "propertyName", "valueSchema", diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/README.md similarity index 86% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/README.md index 284de65..9a24cec 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/README.md +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/README.md @@ -22,4 +22,8 @@ Here are some examples: mapInstVarsFor: Point; for: #ArrayOfPoints customDo: [ :mapping | mapping listOfElementSchema: Point ]; - nextAs: #ArrayOfPoints. \ No newline at end of file + nextAs: #ArrayOfPoints. + + (NeoJSONReader on: '[ { "x" : 1, "y" : 2 }, { "x" : 3, "y" : 4 } ]' readStream) + mapInstVarsFor: Point; + nextListAs: Point. \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesCustomParsing.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesCustomParsing.st new file mode 100644 index 0000000..97d95fd --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesCustomParsing.st @@ -0,0 +1,9 @@ +example +exampleCoordinatesCustomParsing + + | reader | + reader := self on: self exampleCoordinatesJSON readStream. + reader mapAllInstVarsFor: Point. + reader for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]. + ^ reader nextAs: #ArrayOfPoints \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesGenericParsing.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesGenericParsing.st new file mode 100644 index 0000000..589be20 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesGenericParsing.st @@ -0,0 +1,4 @@ +example +exampleCoordinatesGenericParsing + + ^ self fromString: self exampleCoordinatesJSON \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesJSON.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesJSON.st new file mode 100644 index 0000000..e0e9360 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/exampleCoordinatesJSON.st @@ -0,0 +1,4 @@ +example +exampleCoordinatesJSON + + ^ '[{"x":0,"y":0},{"x":1,"y":2},{"x":2,"y":4},{"x":3,"y":6},{"x":4,"y":8}]' \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString.as..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString.as..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString.as..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/fromString.as..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/class/on..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/class/on..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/class/on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/atEnd.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/atEnd.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/atEnd.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/atEnd.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/close.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/close.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/close.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/close.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/consumeWhitespace.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/consumeWhitespace.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/consumeWhitespace.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/consumeWhitespace.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/error..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/error..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/error..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/error..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/expectChar..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/expectChar..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/expectChar..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/expectChar..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/failIfNotAtEnd.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/failIfNotAtEnd.st new file mode 100644 index 0000000..2db27e9 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/failIfNotAtEnd.st @@ -0,0 +1,4 @@ +parsing +failIfNotAtEnd + self atEnd + ifFalse: [ self error: 'extraneous input detected' ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/initialize.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/initialize.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/initialize.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/initialize.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/listClass.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/mapClass.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/match.do..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/match.do..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/match.do..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/match.do..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/matchChar..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/matchChar..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/matchChar..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/matchChar..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/next.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/next.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/next.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/next.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextAs..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextAs..st similarity index 72% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextAs..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextAs..st index 523ac07..d41ad39 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextAs..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextAs..st @@ -1,7 +1,8 @@ accessing nextAs: schema "Secondary interface to parse JSON. - Return objects according to schema." + Return an object according to schema. + If schema is nil, act like #next" | mapping | schema ifNil: [ ^ self next ]. diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextListAs..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextListAs..st new file mode 100644 index 0000000..564fd76 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/nextListAs..st @@ -0,0 +1,8 @@ +accessing +nextListAs: schema + "Secondary interface to parse JSON. + Return a list of objects, each element according to schema." + + ^ self listClass streamContents: [ :stream | + self parseListDo: [ + stream nextPut: (self nextAs: schema) ] ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/on..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/on..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacter.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacter.st similarity index 67% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacter.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacter.st index 5aff6a9..b71f65f 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacter.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacter.st @@ -9,4 +9,6 @@ parseCharacter ifTrue: [ ^ self unescapeChar: char ]. char = $u ifTrue: [ ^ self parseCharacterHex ]. - self error: 'invalid escape character \' , (String with: char) \ No newline at end of file + char + ifNil: [ self error: 'invalid escape, end of file' ] + ifNotNil: [ self error: 'invalid escape character \' , char asString ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex.st new file mode 100644 index 0000000..1fd5f46 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex.st @@ -0,0 +1,16 @@ +private +parseCharacterHex + | value codePoint | + value := self parseCharacterHex4Value. + (value < 16rD800 or: [ value > 16rDBFF ]) + ifTrue: [ codePoint := value ] + ifFalse: [ | leadSurrogate trailSurrogate | + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + "See https://tools.ietf.org/html/rfc7159#section-7" + leadSurrogate := value. + trailSurrogate := self parseTrailingSurrogateHexEscape. + codePoint := (leadSurrogate - 16rD800) * 16r400 + (trailSurrogate - 16rDC00). + codePoint := 16r10000 + codePoint. + codePoint > 16r10FFFF + ifTrue: [ self error: 'Character Unicode code point outside encoder range' ] ]. + ^ Character codePoint: codePoint \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex4Value.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex4Value.st new file mode 100644 index 0000000..9d003b5 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex4Value.st @@ -0,0 +1,7 @@ +private +parseCharacterHex4Value + | value | + value := self parseCharacterHexDigit. + 3 timesRepeat: [ + value := (value << 4) + self parseCharacterHexDigit ]. + ^ value diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHexDigit.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHexDigit.st similarity index 97% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHexDigit.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHexDigit.st index 54b1762..0456f7a 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHexDigit.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHexDigit.st @@ -1,4 +1,4 @@ -parsing +private parseCharacterHexDigit | digit | readStream atEnd diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseConstantDo..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseConstantDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseConstantDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseConstantDo..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseList.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseList.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseList.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseList.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListDo..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListDo..st similarity index 65% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListDo..st index f5593b7..4eb0a50 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListDo..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListDo..st @@ -8,5 +8,6 @@ parseListDo: block block value. (self matchChar: $]) ifTrue: [ ^ self ]. - self expectChar: $, ]. - self error: 'end of list expected' \ No newline at end of file + (self matchChar: $,) + ifFalse: [ self error: ', or ] expected' ] ]. + self error: 'incomplete list' \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListElementsDo..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListElementsDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListElementsDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseListElementsDo..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMap.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMap.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMap.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMap.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapDo..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapDo..st similarity index 65% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapDo..st index a95eb50..df2fdf2 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapDo..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapDo..st @@ -7,5 +7,6 @@ parseMapDo: block block value. (self matchChar: $}) ifTrue: [ ^ self ]. - self expectChar: $, ]. - self error: 'end of map expected' \ No newline at end of file + (self matchChar: $,) + ifFalse: [ self error: ', or } expected' ] ]. + self error: 'incomplete map' \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysAndValuesDo..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysAndValuesDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysAndValuesDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysAndValuesDo..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysDo..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseMapKeysDo..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumber.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumber.st similarity index 59% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumber.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumber.st index 512df2f..969af72 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumber.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumber.st @@ -1,12 +1,14 @@ parsing parseNumber - | negated number | + | negated number isFloat | negated := readStream peekFor: $-. number := self parseNumberInteger. - (readStream peekFor: $.) - ifTrue: [ number := number + self parseNumberFraction ]. + isFloat := (readStream peekFor: $.) + ifTrue: [ number := number + self parseNumberFraction. true ] + ifFalse: [ false ]. ((readStream peekFor: $e) or: [ readStream peekFor: $E ]) ifTrue: [ number := number * self parseNumberExponent ]. + isFloat ifTrue: [ number := number asFloat ]. negated ifTrue: [ number := number negated ]. self consumeWhitespace. diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberExponent.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberExponent.st similarity index 52% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberExponent.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberExponent.st index 8df2f4c..e5a310a 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberExponent.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberExponent.st @@ -4,8 +4,13 @@ parseNumberExponent number := 0. (negated := readStream peekFor: $-) ifFalse: [ readStream peekFor: $+ ]. + (readStream atEnd or: [ readStream peek isDigit not ]) + ifTrue: [ self error: 'number exponent expected' ]. [ readStream atEnd not and: [ readStream peek isDigit ] ] whileTrue: [ number := 10 * number + readStream next digitValue ]. negated ifTrue: [ number := number negated ]. + number positive + ifTrue: [ number > Float emax ifTrue: [ self error: 'number exponent too large' ] ] + ifFalse: [ number < Float emin ifTrue: [ self error: 'number exponent too small' ] ]. ^ 10 raisedTo: number \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberFraction.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberFraction.st similarity index 82% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberFraction.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberFraction.st index 2e03bc8..40f2d92 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberFraction.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberFraction.st @@ -2,9 +2,9 @@ parsing parseNumberFraction | number power | number := 0. - power := 1.0. + power := 1. [ readStream atEnd not and: [ readStream peek isDigit ] ] whileTrue: [ number := 10 * number + readStream next digitValue. - power := power * 10.0 ]. + power := power * 10 ]. ^ number / power \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberInteger.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberInteger.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberInteger.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseNumberInteger.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parsePropertyName.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parsePropertyName.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parsePropertyName.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parsePropertyName.st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseString.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseString.st new file mode 100644 index 0000000..ea36a0f --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseString.st @@ -0,0 +1,10 @@ +parsing +parseString + | result | + (readStream peekFor: $") + ifFalse: [ self error: '" expected' ]. + result := self stringStreamContents: [ :stream | + [ readStream atEnd or: [ readStream peek = $" ] ] + whileFalse: [ stream nextPut: self parseCharacter ] ]. + self expectChar: $". + ^ result \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHex.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHex.st similarity index 98% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHex.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHex.st index f9bd260..97e7e13 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHex.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHex.st @@ -14,4 +14,4 @@ Parse the trailingSurrogate pair." , (String with: char) ]. value := self parseCharacterHexDigit. 3 timesRepeat: [ value := (value << 4) + self parseCharacterHexDigit ]. - ^ value \ No newline at end of file + ^ value diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHexEscape.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHexEscape.st new file mode 100644 index 0000000..00fbbda --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseTrailingSurrogateHexEscape.st @@ -0,0 +1,5 @@ +private +parseTrailingSurrogateHexEscape + (readStream next = $\ and: [ readStream next = $u ]) + ifTrue: [ ^ self parseCharacterHex4Value ] + ifFalse: [ self error: 'trailing surrogate hex escape expected' ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseValue.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseValue.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseValue.st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseValue.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/propertyNamesAsSymbols..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/propertyNamesAsSymbols..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/propertyNamesAsSymbols..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/propertyNamesAsSymbols..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamClass.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamClass.st new file mode 100644 index 0000000..ea6c8ee --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamClass.st @@ -0,0 +1,8 @@ +private +stringStreamClass + "Answer the class of the collection used for the stringStream of receiver. + + NOTE: It is String, but if receiver's readStream is over + another class of String, then this provides compatibility for that." + + ^ readStream collectionSpecies \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamContents..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamContents..st similarity index 69% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamContents..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamContents..st index ab32e4c..0d6ac01 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamContents..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/stringStreamContents..st @@ -2,10 +2,9 @@ private stringStreamContents: block "Like String streamContents: block but reusing the underlying buffer for improved efficiency" - - stringStream - ifNil: [ - stringStream := (String new: 32) writeStream ]. + + stringStream ifNil: [ + stringStream := (self stringStreamClass new: 32) writeStream ]. stringStream reset. block value: stringStream. ^ stringStream contents \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/unescapeChar..st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/unescapeChar..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/unescapeChar..st rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/unescapeChar..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/upToEnd.st b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/upToEnd.st new file mode 100644 index 0000000..7b944ef --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/instance/upToEnd.st @@ -0,0 +1,8 @@ +accessing +upToEnd + "Parse and collect JSON values from my stream until it ends, returning the collection. + This supports Newline delimited JSON (application/x-ndjson) & JSON Lines (application/jsonl). + Warning: though each element is valid JSON, taken as a whole the result is non-valid JSON." + + ^ Array streamContents: [ :out | + [ self atEnd ] whileFalse: [ out nextPut: self next ] ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/properties.json similarity index 89% rename from repository/Neo-JSON-Core.package/NeoJSONReader.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONReader.class/properties.json index e7732a1..74a8182 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONReader.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "readStream", "stringStream", diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/README.md diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/class/on..st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/class/on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/class/on..st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/class/on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/initialize.st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/initialize.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/initialize.st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/initialize.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/on..st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/on..st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/wasUsed.st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/wasUsed.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/wasUsed.st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/wasUsed.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement..st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement..st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement.as..st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement.as..st new file mode 100644 index 0000000..e3c7106 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeElement.as..st @@ -0,0 +1,9 @@ +writing +writeElement: value as: valueSchema + first + ifTrue: [ + jsonWriter newlineIndent. + first := false ] + ifFalse: [ + jsonWriter listElementSeparator ]. + jsonWriter nextPut: value as: valueSchema \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value..st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value..st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value.as..st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value.as..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value.as..st rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeKey.value.as..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeNil.st b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeNil.st new file mode 100644 index 0000000..eb17c6d --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/instance/writeNil.st @@ -0,0 +1,3 @@ +accessing +writeNil + ^ jsonWriter writeNil \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/properties.json similarity index 86% rename from repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/properties.json index 21df003..af4ad5a 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "jsonWriter", "first" ], diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/README.md b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/README.md rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/README.md diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinates.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinates.st new file mode 100644 index 0000000..a8b7656 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinates.st @@ -0,0 +1,4 @@ +example +exampleCoordinates + + ^ { 0@0 . 1@2. 2@4. 3@6 . 4@8} \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesCustomWriting.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesCustomWriting.st new file mode 100644 index 0000000..968cc9e --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesCustomWriting.st @@ -0,0 +1,8 @@ +example +exampleCoordinatesCustomWriting + + ^ String streamContents: [ :out | + | writer | + writer := self on: out. + writer mapAllInstVarsFor: Point. + writer nextPut: self exampleCoordinates ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesGeneric.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesGeneric.st new file mode 100644 index 0000000..83f9226 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesGeneric.st @@ -0,0 +1,4 @@ +example +exampleCoordinatesGeneric + + ^ (0 to: 4) collect: [ :each | { 'x' -> each . 'y' -> (each * 2) } asDictionary ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesGenericWriting.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesGenericWriting.st new file mode 100644 index 0000000..704ec66 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/exampleCoordinatesGenericWriting.st @@ -0,0 +1,4 @@ +example +exampleCoordinatesGenericWriting + + ^ self toString: self exampleCoordinatesGeneric \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/class/on..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/class/on..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/class/toString..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/toString..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/class/toString..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/toString..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/class/toStringPretty..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/toStringPretty..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/class/toStringPretty..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/class/toStringPretty..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/asciiOnly..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/asciiOnly..st new file mode 100644 index 0000000..14b2730 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/asciiOnly..st @@ -0,0 +1,5 @@ +initialize-release +asciiOnly: boolean + "Set whether I should escape all non ASCII characters or not" + + asciiOnly := boolean \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/close.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/close.st similarity index 70% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/close.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/close.st index 2754652..73b1b7d 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/close.st +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/close.st @@ -1,5 +1,7 @@ initialize-release close + "Close the stream that I write to" + writeStream ifNotNil: [ writeStream close. writeStream := nil ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/doesCodePointNeedEscaping..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/doesCodePointNeedEscaping..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/doesCodePointNeedEscaping..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/doesCodePointNeedEscaping..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeChar..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeChar..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeChar..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeChar..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey..st new file mode 100644 index 0000000..6b9ae2d --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey..st @@ -0,0 +1,7 @@ +private +encodeKey: key + key isString ifFalse: [ ^ self error: 'JSON key names in objects must be strings' ]. + self nextPut: key. + self prettyPrintSpace. + writeStream nextPut: $:. + self prettyPrintSpace \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value..st new file mode 100644 index 0000000..e6faeff --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value..st @@ -0,0 +1,4 @@ +private +encodeKey: key value: value + self encodeKey: key. + self nextPut: value \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value.as..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value.as..st new file mode 100644 index 0000000..0a83859 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value.as..st @@ -0,0 +1,4 @@ +private +encodeKey: key value: value as: valueSchema + self encodeKey: key. + self nextPut: value as: valueSchema \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeChar..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeChar..st new file mode 100644 index 0000000..0924ae3 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeChar..st @@ -0,0 +1,19 @@ +private +escapeChar: code + code = 34 + ifTrue: [ ^ writeStream nextPutAll: '\"' ]. + code = 92 + ifTrue: [ ^ writeStream nextPutAll: '\\' ]. + code = 47 + ifTrue: [ ^ writeStream nextPutAll: '\/' ]. + code = 8 + ifTrue: [ ^ writeStream nextPutAll: '\b' ]. + code = 12 + ifTrue: [ ^ writeStream nextPutAll: '\f' ]. + code = 10 + ifTrue: [ ^ writeStream nextPutAll: '\n' ]. + code = 13 + ifTrue: [ ^ writeStream nextPutAll: '\r' ]. + code = 9 + ifTrue: [ ^ writeStream nextPutAll: '\t' ]. + self escapeUnicode: code diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeUnicode..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeUnicode..st new file mode 100644 index 0000000..702458f --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeUnicode..st @@ -0,0 +1,15 @@ +private +escapeUnicode: codePoint + codePoint <= 16rFFFF + ifTrue: [ self escapeUnicode4: codePoint ] + ifFalse: [ + codePoint <= 16r10FFFF + ifTrue: [ | leadSurrogate trailSurrogate shifted | + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + "See https://tools.ietf.org/html/rfc7159#section-7" + shifted := codePoint - 16r10000. + leadSurrogate := 16rD800 + (shifted // 16r400). + trailSurrogate := 16rDC00 + (shifted \\ 16r400). + self escapeUnicode4: leadSurrogate. + self escapeUnicode4: trailSurrogate ] + ifFalse: [ self error: 'Character Unicode code point outside encoder range' ] ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeUnicode4..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeUnicode4..st new file mode 100644 index 0000000..0bfa39c --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeUnicode4..st @@ -0,0 +1,4 @@ +private +escapeUnicode4: codePoint + writeStream nextPutAll: '\u'. + codePoint printOn: writeStream base: 16 nDigits: 4 \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/floatPrinter..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/floatPrinter..st new file mode 100644 index 0000000..6ae72af --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/floatPrinter..st @@ -0,0 +1,6 @@ +initialize-release +floatPrinter: anObject + "Set the float print, an object that implements #printFloat:on: + By default, I am my own float printer" + + floatPrinter := anObject \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/indentedDo..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/indentedDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/indentedDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/indentedDo..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/initialize.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/initialize.st new file mode 100644 index 0000000..a63f3bb --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/initialize.st @@ -0,0 +1,9 @@ +initialize-release +initialize + super initialize. + self newLine: String lf. + self prettyPrint: false. + self asciiOnly: false. + self writeNil: false. + self floatPrinter: self. + level := 0 \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/listElementSeparator.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/listElementSeparator.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/listElementSeparator.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/listElementSeparator.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/mapElementSeparator.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/mapElementSeparator.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/mapElementSeparator.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/mapElementSeparator.st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newLine..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newLine..st new file mode 100644 index 0000000..16be4fb --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newLine..st @@ -0,0 +1,5 @@ +initialize-release +newLine: string + "Set the newline string that I should use when pretty printing" + + newLine := string \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newline.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newline.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newline.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newline.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newlineIndent.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newlineIndent.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newlineIndent.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newlineIndent.st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut..st new file mode 100644 index 0000000..3bee296 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut..st @@ -0,0 +1,5 @@ +accessing +nextPut: anObject + "Primary interface. Write a JSON representation of anObject to my stream." + + anObject neoJsonOn: self \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut.as..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut.as..st similarity index 72% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut.as..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut.as..st index c7e698d..e13f80c 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut.as..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut.as..st @@ -4,6 +4,6 @@ nextPut: anObject as: schema Write objects according to schema." | mapping | - schema ifNil: [ ^ self nextPut: anObject ]. + (schema isNil or: [ anObject isNil ]) ifTrue: [ ^ self nextPut: anObject ]. mapping := self mappingFor: schema. ^ mapping writeObject: anObject on: self \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPutAll..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPutAll..st new file mode 100644 index 0000000..37eff36 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPutAll..st @@ -0,0 +1,9 @@ +accessing +nextPutAll: aCollection + "Write a separate JSON representation of all objects in aCollection to my stream. + This supports Newline delimited JSON (application/x-ndjson) & JSON Lines (application/jsonl). + Warning: though each element is valid JSON, taken as a whole the result is non-valid JSON." + + aCollection do: [ :each | + self nextPut: each. + self newline ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/on..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/on..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/on..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/on..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrint..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrint..st similarity index 51% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrint..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrint..st index 413ae6e..4f00d06 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrint..st +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrint..st @@ -1,3 +1,5 @@ initialize-release prettyPrint: boolean + "Set whether I should pretty print the JSON that I write" + prettyPrint := boolean \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrintSpace.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrintSpace.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrintSpace.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/prettyPrintSpace.st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/printFloat.on..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/printFloat.on..st new file mode 100644 index 0000000..49035bb --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/printFloat.on..st @@ -0,0 +1,5 @@ +printing +printFloat: float on: stream + "See NeoJSONFloatPrinter for a custom float printer" + + float printOn: stream \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeBoolean..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeBoolean..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeBoolean..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeBoolean..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeFloat..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeFloat..st new file mode 100644 index 0000000..7006032 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeFloat..st @@ -0,0 +1,3 @@ +writing +writeFloat: float + floatPrinter printFloat: float on: writeStream \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeInteger..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeInteger..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeInteger..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeInteger..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeList..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeList..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeList..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeList..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeListStreamingDo..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeListStreamingDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeListStreamingDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeListStreamingDo..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMap..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMap..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMap..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMap..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMapStreamingDo..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMapStreamingDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMapStreamingDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeMapStreamingDo..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNil..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNil..st new file mode 100644 index 0000000..c51986c --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNil..st @@ -0,0 +1,5 @@ +initialize-release +writeNil: boolean + "Set whether I will write nil/null properties of objects or skip them." + + writeNil := boolean \ No newline at end of file diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNil.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNil.st new file mode 100644 index 0000000..f6d78d5 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNil.st @@ -0,0 +1,5 @@ +accessing +writeNil + "Return whether I will write nil/null properties of objects or skip them." + + ^ writeNil \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNull.st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNull.st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNull.st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeNull.st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeObject..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeObject..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeObject..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeObject..st diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeStreamingDo..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeStreamingDo..st similarity index 100% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeStreamingDo..st rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeStreamingDo..st diff --git a/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeString..st b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeString..st new file mode 100644 index 0000000..e2107ed --- /dev/null +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeString..st @@ -0,0 +1,6 @@ +writing +writeString: string + writeStream nextPut: $". + 1 to: string size do: [ :index | + self encodeChar: (string at: index) ]. + writeStream nextPut: $" \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/properties.json b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/properties.json similarity index 78% rename from repository/Neo-JSON-Core.package/NeoJSONWriter.class/properties.json rename to filetree/Neo-JSON-Core.package/NeoJSONWriter.class/properties.json index da76840..dc270f6 100644 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/properties.json +++ b/filetree/Neo-JSON-Core.package/NeoJSONWriter.class/properties.json @@ -4,13 +4,15 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "writeStream", "prettyPrint", "level", "newLine", - "asciiOnly" ], + "asciiOnly", + "writeNil", + "floatPrinter" ], "name" : "NeoJSONWriter", "pools" : [ ], diff --git a/repository/Neo-JSON-Core.package/Number.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/Number.extension/instance/neoJsonOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/Number.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/Number.extension/instance/neoJsonOn..st diff --git a/repository/Neo-JSON-Core.package/Number.extension/properties.json b/filetree/Neo-JSON-Core.package/Number.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/Number.extension/properties.json rename to filetree/Neo-JSON-Core.package/Number.extension/properties.json diff --git a/repository/Neo-JSON-Core.package/Object.extension/instance/instVarIndexFor.ifAbsent..st b/filetree/Neo-JSON-Core.package/Object.extension/instance/instVarIndexFor.ifAbsent..st similarity index 95% rename from repository/Neo-JSON-Core.package/Object.extension/instance/instVarIndexFor.ifAbsent..st rename to filetree/Neo-JSON-Core.package/Object.extension/instance/instVarIndexFor.ifAbsent..st index 750f4f7..ae14c80 100644 --- a/repository/Neo-JSON-Core.package/Object.extension/instance/instVarIndexFor.ifAbsent..st +++ b/filetree/Neo-JSON-Core.package/Object.extension/instance/instVarIndexFor.ifAbsent..st @@ -4,4 +4,4 @@ instVarIndexFor: anInstVarNameString ifAbsent: aBlock idx := self allInstVarNames indexOf: anInstVarNameString asSymbol. idx = 0 ifTrue: [ ^ aBlock value ]. - ^ idx \ No newline at end of file + ^ idx diff --git a/repository/Neo-JSON-Core.package/Object.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/Object.extension/instance/neoJsonOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/Object.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/Object.extension/instance/neoJsonOn..st diff --git a/repository/Neo-JSON-Core.package/Object.extension/properties.json b/filetree/Neo-JSON-Core.package/Object.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/Object.extension/properties.json rename to filetree/Neo-JSON-Core.package/Object.extension/properties.json diff --git a/filetree/Neo-JSON-Core.package/String.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/String.extension/instance/neoJsonOn..st new file mode 100644 index 0000000..0c7c676 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/String.extension/instance/neoJsonOn..st @@ -0,0 +1,3 @@ +*neo-json-core +neoJsonOn: neoJSONWriter + neoJSONWriter writeString: self diff --git a/filetree/Neo-JSON-Core.package/String.extension/properties.json b/filetree/Neo-JSON-Core.package/String.extension/properties.json new file mode 100644 index 0000000..ef44348 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/String.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "String" } + diff --git a/repository/Neo-JSON-Core.package/UndefinedObject.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Core.package/UndefinedObject.extension/instance/neoJsonOn..st similarity index 100% rename from repository/Neo-JSON-Core.package/UndefinedObject.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Core.package/UndefinedObject.extension/instance/neoJsonOn..st diff --git a/repository/Neo-JSON-Core.package/UndefinedObject.extension/properties.json b/filetree/Neo-JSON-Core.package/UndefinedObject.extension/properties.json similarity index 100% rename from repository/Neo-JSON-Core.package/UndefinedObject.extension/properties.json rename to filetree/Neo-JSON-Core.package/UndefinedObject.extension/properties.json diff --git a/filetree/Neo-JSON-Core.package/properties.json b/filetree/Neo-JSON-Core.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-Core.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/.filetree b/filetree/Neo-JSON-GemStone-Core.package/.filetree similarity index 100% rename from repository/Neo-JSON-Core.package/.filetree rename to filetree/Neo-JSON-GemStone-Core.package/.filetree diff --git a/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/class/negativeInfinity.st b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/class/negativeInfinity.st new file mode 100644 index 0000000..79f7aeb --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/class/negativeInfinity.st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +negativeInfinity + + ^ self fromString: 'MinusInfinity' \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/class/zero.st b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/class/zero.st new file mode 100644 index 0000000..c4b78c1 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/class/zero.st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +zero + + ^ 0.0 \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/instance/isFinite.st b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/instance/isFinite.st new file mode 100644 index 0000000..a9f5c8e --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/instance/isFinite.st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +isFinite + + ^(self - self) = 0.0 \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/instance/isZero.st b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/instance/isZero.st new file mode 100644 index 0000000..7f88ea6 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/instance/isZero.st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +isZero + + ^ self = 0.0 \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/properties.json b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/properties.json new file mode 100644 index 0000000..b3b882e --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/BinaryFloat.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "BinaryFloat" } diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/asCharacterDigit.st b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/asCharacterDigit.st new file mode 100644 index 0000000..edb0732 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/asCharacterDigit.st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +asCharacterDigit + + ^ Character digitValue: self \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/digitAt.base..st b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/digitAt.base..st new file mode 100644 index 0000000..2cc9604 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/digitAt.base..st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +digitAt: anExponent base: base + + ^ self // (base raisedToInteger: anExponent - 1) \\ base diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/isPowerOfTwo.st b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/isPowerOfTwo.st new file mode 100644 index 0000000..0b420a8 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/isPowerOfTwo.st @@ -0,0 +1,4 @@ +*neo-json-gemstone-core +isPowerOfTwo + "Return true if the receiver is an integral power of two." + ^ self ~= 0 and: [ (self bitAnd: self-1) = 0 ] \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/numberOfDigitsInBase..st b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/numberOfDigitsInBase..st new file mode 100644 index 0000000..4995891 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/numberOfDigitsInBase..st @@ -0,0 +1,30 @@ +*neo-json-gemstone-core +numberOfDigitsInBase: b + "Return how many digits are necessary to print this number in base b. + This does not count any place for minus sign, radix prefix or whatever. + Note that this algorithm may cost a few operations on LargeInteger." + + | nDigits q total | + self negative ifTrue: [^self negated numberOfDigitsInBase: b]. + self < b ifTrue: [^1]. + b isPowerOfTwo ifTrue: [^self highBit + b highBit - 2 quo: b highBit - 1]. + + "A conversion from base 2 to base b has to be performed. + This algorithm avoids Float computations like (self log: b) floor + 1, + 1) because they are inexact + 2) because LargeInteger might overflow + 3) because this algorithm might be cheaper than conversion" + + q := self. + total := 0. + ["Make an initial nDigits guess that is lower than or equal to required number of digits" + nDigits := b = 10 + ifTrue: [((q highBit - 1) * 1233 >> 12) + 1. "This is because (2 log)/(10 log)*4096 is slightly greater than 1233"] + ifFalse: [q highBit quo: b highBit]. + total := total + nDigits. + + "See how many digits remains above these first nDigits guess" + (q := q quo: (b raisedToInteger: nDigits)) < b] whileFalse. + ^q = 0 + ifTrue: [total] + ifFalse: [total + 1] \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/printOn.base.length.padded..st b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/printOn.base.length.padded..st new file mode 100644 index 0000000..8d93f4d --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/printOn.base.length.padded..st @@ -0,0 +1,15 @@ +*neo-json-gemstone-core +printOn: aStream base: base length: minimum padded: zeroFlag + "Return a String representation of this number in base b with a minimum length and padded by 0 if zeroFlag is set" + + "(String streamContents: [ :s | 10 printOn: s base: 10 length: 4 padded: true] ) >>> '0010'" + "(String streamContents: [ :s | -10 printOn: s base: 10 length: 4 padded: true] ) >>> '-010'" + + | prefix | + prefix := self negative ifTrue: ['-'] ifFalse: [ '' ]. + self + print: (self abs printStringBase: base) + on: aStream + prefix: prefix + length: minimum + padded: zeroFlag \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/printOn.on.prefix.length.padded..st b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/printOn.on.prefix.length.padded..st new file mode 100644 index 0000000..65bc397 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/instance/printOn.on.prefix.length.padded..st @@ -0,0 +1,14 @@ +*neo-json-gemstone-core +print: positiveNumberString on: aStream prefix: prefix length: minimum padded: zeroFlag + "Return a String based on concatenation of positiveNumberString with prefix then padded by 0 is zeroFlag is set for a minimum length." + + "(String streamContents: [ :s | 10 print: '10' on: s prefix: 'zz' length: 4 padded: true ] ) >>> 'zz10'" + + | padLength | + padLength := minimum - positiveNumberString size - prefix size. + padLength > 0 + ifTrue: [ zeroFlag + ifTrue: [ aStream nextPutAll: prefix; nextPutAll: (String new: padLength withAll: $0) ] + ifFalse: [ aStream nextPutAll: (String new: padLength withAll: Character space); nextPutAll: prefix ] ] + ifFalse: [ aStream nextPutAll: prefix ]. + aStream nextPutAll: positiveNumberString \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/properties.json b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/properties.json new file mode 100644 index 0000000..d27420b --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/Integer.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "Integer" } diff --git a/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/class/newFromPairs..st b/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/class/newFromPairs..st new file mode 100644 index 0000000..1c78715 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/class/newFromPairs..st @@ -0,0 +1,12 @@ +*neo-json-gemstone-core +newFromPairs: anArray + "Answer an instance of me associating (anArray at:i) to (anArray at: i+i) + for each odd i. anArray must have an even number of entries. + Dictionary newFromPairs: {'Red' . Color red . 'Blue' . Color blue . 'Green' . Color green}. " + | newDictionary | + + newDictionary := self new: (anArray size/2). + 1 to: (anArray size-1) by: 2 do: [ :i| + newDictionary at: (anArray at: i) put: (anArray at: i+1). + ]. + ^ newDictionary diff --git a/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/instance/neoJsonOn..st new file mode 100644 index 0000000..d439874 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/instance/neoJsonOn..st @@ -0,0 +1,3 @@ +*neo-json-gemstone-core +neoJsonOn: neoJSONWriter + neoJSONWriter writeMap: self \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/properties.json b/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/properties.json new file mode 100644 index 0000000..564db8e --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/KeyValueDictionary.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "KeyValueDictionary" } diff --git a/repository/Neo-JSON-Core.package/CharacterCollection.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-GemStone-Core.package/MultiByteString.extension/instance/neoJsonOn..st similarity index 70% rename from repository/Neo-JSON-Core.package/CharacterCollection.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-GemStone-Core.package/MultiByteString.extension/instance/neoJsonOn..st index b41f066..7269bb0 100644 --- a/repository/Neo-JSON-Core.package/CharacterCollection.extension/instance/neoJsonOn..st +++ b/filetree/Neo-JSON-GemStone-Core.package/MultiByteString.extension/instance/neoJsonOn..st @@ -1,3 +1,3 @@ -*neo-json-core +*neo-json-gemstone-core neoJsonOn: neoJSONWriter neoJSONWriter writeString: self \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/MultiByteString.extension/properties.json b/filetree/Neo-JSON-GemStone-Core.package/MultiByteString.extension/properties.json new file mode 100644 index 0000000..274cdff --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/MultiByteString.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "MultiByteString" } diff --git a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st new file mode 100644 index 0000000..67567b0 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/numberOfDigitsInBase..st @@ -0,0 +1,8 @@ +*neo-json-gemstone-core +numberOfDigitsInBase: b + "Return how many digits are necessary to print this number in base b. + Mostly same as super but an optimized version for base 10 case" + + b = 10 ifFalse: [^super numberOfDigitsInBase: b]. + self < 0 ifTrue: [^self negated numberOfDigitsInBase: b]. + ^self decimalDigitLength diff --git a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/printOn.base.length.padded..st b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/printOn.base.length.padded..st new file mode 100644 index 0000000..cf6b585 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/printOn.base.length.padded..st @@ -0,0 +1,33 @@ +*neo-json-gemstone-core +printOn: stream base: base length: minimumLength padded: padWithZeroes + "Return a String representation of this number in base b with a minimum length and padded by 0 if zeroFlag is set" + + "(String streamContents: [ :s | 10 printOn: s base: 10 length: 4 padded: true] ) >>> '0010'" + "(String streamContents: [ :s | -10 printOn: s base: 10 length: 4 padded: true] ) >>> '-010'" + + | n numberOfDigits totalLength divisor | + self < 0 + ifTrue: [ + n := self negated. + totalLength := 1 ] + ifFalse: [ + n := self. + totalLength := 0 ]. + numberOfDigits := n numberOfDigitsInBase: base. + totalLength := totalLength + numberOfDigits. + padWithZeroes ifFalse: [ + [ totalLength < minimumLength ] whileTrue: [ + stream space. + totalLength := totalLength + 1 ] ]. + n = self ifFalse: [ stream nextPut: $- ]. + padWithZeroes ifTrue: [ + [ totalLength < minimumLength ] whileTrue: [ + stream nextPut: $0. + totalLength := totalLength + 1 ] ]. + divisor := (base raisedToInteger: numberOfDigits - 1). + [ divisor > 0 ] whileTrue: [ + | digit | + digit := n // divisor. + stream nextPut: ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' at: digit + 1). + n := n - (digit * divisor). + divisor := divisor // base ] \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/printOn.base.nDigits..st b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/printOn.base.nDigits..st new file mode 100644 index 0000000..17b778f --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/instance/printOn.base.nDigits..st @@ -0,0 +1,6 @@ +*neo-json-gemstone-core +printOn: aStream base: b nDigits: n + "Append a representation of this number in base b on aStream using nDigits. + self must be positive." + + self printOn: aStream base: b length: n padded: true \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/properties.json b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/properties.json new file mode 100644 index 0000000..d2d9ab4 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/SmallInteger.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "SmallInteger" } diff --git a/filetree/Neo-JSON-GemStone-Core.package/properties.json b/filetree/Neo-JSON-GemStone-Core.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Core.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/.filetree b/filetree/Neo-JSON-GemStone-Examples.package/.filetree similarity index 100% rename from repository/Neo-JSON-Tests.package/.filetree rename to filetree/Neo-JSON-GemStone-Examples.package/.filetree diff --git a/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/README.md b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/README.md similarity index 100% rename from repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/README.md rename to filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/README.md diff --git a/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/instance/fileName..st b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/instance/fileName..st new file mode 100644 index 0000000..3966e08 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/instance/fileName..st @@ -0,0 +1,3 @@ +accessing +fileName: anObject + fileName := anObject \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/instance/url..st b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/instance/url..st new file mode 100644 index 0000000..ca05f95 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/instance/url..st @@ -0,0 +1,3 @@ +accessing +url: anObject + url := anObject \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json new file mode 100644 index 0000000..d27738c --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/Attachment.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "Neo-JSON-Gemstone-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "url", + "fileName" ], + "name" : "Attachment", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/README.md b/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/README.md rename to filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/README.md diff --git a/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json new file mode 100644 index 0000000..3888853 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/BittrexResponse.class/properties.json @@ -0,0 +1,16 @@ +{ + "category" : "Neo-JSON-Gemstone-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "success", + "message", + "result" ], + "name" : "BittrexResponse", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/BaselineOfNeoJSON.package/monticello.meta/initializers.st b/filetree/Neo-JSON-GemStone-Examples.package/Market.class/README.md similarity index 100% rename from repository/BaselineOfNeoJSON.package/monticello.meta/initializers.st rename to filetree/Neo-JSON-GemStone-Examples.package/Market.class/README.md diff --git a/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json new file mode 100644 index 0000000..735a637 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/Market.class/properties.json @@ -0,0 +1,24 @@ +{ + "category" : "Neo-JSON-Gemstone-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "MarketCurrency", + "BaseCurrency", + "MarketCurrencyLong", + "BaseCurrencyLong", + "MinTradeSize", + "MarketName", + "IsActive", + "Created", + "Notice", + "IsSponsored", + "LogoUrl" ], + "name" : "Market", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/ConfigurationOfNeoJSON.package/monticello.meta/initializers.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/README.md similarity index 100% rename from repository/ConfigurationOfNeoJSON.package/monticello.meta/initializers.st rename to filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/README.md diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testAccessingTheNewYorkPublicLibrary.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testAccessingTheNewYorkPublicLibrary.st new file mode 100644 index 0000000..5ba6501 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testAccessingTheNewYorkPublicLibrary.st @@ -0,0 +1,13 @@ +tests +testAccessingTheNewYorkPublicLibrary + + | client reader data networkStream | + (client := ZnClient new) + streaming: true; + url: 'https://github.com/NYPL-publicdomain/data-and-utilities/blob/master/items/pd_items_1.ndjson?raw=true'; + get. + networkStream := ZnCharacterReadStream on: client contents. + reader := NeoJSONReader on: networkStream. + data := Array streamContents: [ :out | [ reader atEnd ] whileFalse: [ out nextPut: reader next ] ]. + client close. + data \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testAttachmentsExample.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testAttachmentsExample.st new file mode 100644 index 0000000..8ded541 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testAttachmentsExample.st @@ -0,0 +1,31 @@ +tests +testAttachmentsExample + | collectionOne json | + "Let's create a collection of two instances:" + collectionOne := {(Attachment new + url: 'http://example.com/random-name.txt' asZnUrl; + fileName: 'chapter-one.txt' yourself). + (Attachment new + url: 'http://example.com/random-name.png' asZnUrl; + fileName: 'image.png'; + yourself)}. + + "And let's map it to a JSON structure:" + json := String + streamContents: [ :aStream | + (NeoJSONWriter on: aStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + mapAllInstVarsFor: Attachment; + for: ZnUrl customDo: [ :mapping | mapping encoder: [ :aZnUrl | aZnUrl asString ] ]; + nextPut: collectionOne as: #CollectionOfAttachments ]. + + + "And read the JSON structure:" + (NeoJSONReader on: json readStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + for: Attachment + do: [ :mapping | + mapping mapInstVar: 'fileName'. + (mapping mapInstVar: 'url') valueSchema: ZnUrl ]; + for: ZnUrl customDo: [ :mapping | mapping decoder: [ :string | string asZnUrl ] ]; + nextAs: #CollectionOfAttachments \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDictionary.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDictionary.st new file mode 100644 index 0000000..82b469f --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDictionary.st @@ -0,0 +1,10 @@ +tests +testBittrexLitecoinAsDictionary + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarketSummary?market=BTC-LTC'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader next ]; + get. + \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDomainObjects.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDomainObjects.st new file mode 100644 index 0000000..f41da9c --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDomainObjects.st @@ -0,0 +1,16 @@ +tests +testBittrexLitecoinAsDomainObjects + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarkets'; + enforceHttpSuccess: true; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader for: BittrexResponse do: [:m| + m mapInstVar: #success. + m mapInstVar: #message. + (m mapInstVar: #result) valueSchema: #ArrayOfMarkets]. + reader for: #ArrayOfMarkets customDo: [ :mapping | mapping listOfElementSchema: Market ]. + reader mapInstVarsFor: Market. + reader nextAs: BittrexResponse ]; + get \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testDoomtownDBCards.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testDoomtownDBCards.st new file mode 100644 index 0000000..41531e4 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testDoomtownDBCards.st @@ -0,0 +1,4 @@ +tests +testDoomtownDBCards + + NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testFeed.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testFeed.st new file mode 100644 index 0000000..476852d --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testFeed.st @@ -0,0 +1,12 @@ +tests +testFeed + | json | + json := ZnClient new + systemPolicy; + url: 'https://daringfireball.net/feeds/json'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | NeoJSONObject fromString: entity contents ]; + get. + json items collect: #title. + json items collect: [ :each | each title -> each url ]. + json \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testGetWorldCapitals.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testGetWorldCapitals.st new file mode 100644 index 0000000..1fe53f1 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testGetWorldCapitals.st @@ -0,0 +1,4 @@ +tests +testGetWorldCapitals + ((NeoJSONReader fromString: (ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) + collect: [ :d | d at: #capital ] \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testGoogleMapsAPI.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testGoogleMapsAPI.st new file mode 100644 index 0000000..85bb04c --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testGoogleMapsAPI.st @@ -0,0 +1,7 @@ +tests +testGoogleMapsAPI + + ZnClient new + url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testParsingUserAgentStrings.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testParsingUserAgentStrings.st new file mode 100644 index 0000000..440e03f --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testParsingUserAgentStrings.st @@ -0,0 +1,9 @@ +tests +testParsingUserAgentStrings + ZnClient new + http; + host: 'useragentstring.com'; + queryAt: 'uas' put: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4'; + queryAt: 'getJSON' put: 'all'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testStackOverflowInfo.st b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testStackOverflowInfo.st new file mode 100644 index 0000000..645a79f --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/instance/testStackOverflowInfo.st @@ -0,0 +1,6 @@ +tests +testStackOverflowInfo + + ZnClient new + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get: 'http://api.stackexchange.com/2.1/info?site=stackoverflow' \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json new file mode 100644 index 0000000..77da182 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/NeoJSONPharoExamples.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Gemstone-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONGemStoneExamples", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/filetree/Neo-JSON-GemStone-Examples.package/properties.json b/filetree/Neo-JSON-GemStone-Examples.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Examples.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/filetree/Neo-JSON-GemStone-Tests.package/.filetree b/filetree/Neo-JSON-GemStone-Tests.package/.filetree new file mode 100644 index 0000000..8998102 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Tests.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/filetree/Neo-JSON-GemStone-Tests.package/properties.json b/filetree/Neo-JSON-GemStone-Tests.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-GemStone-Tests.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Core.package/.filetree b/filetree/Neo-JSON-Pharo-Core.package/.filetree new file mode 100644 index 0000000..8998102 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Core.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/repository/Neo-JSON-Core.package/Dictionary.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st similarity index 72% rename from repository/Neo-JSON-Core.package/Dictionary.extension/instance/neoJsonOn..st rename to filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st index 174eb53..61a9c65 100644 --- a/repository/Neo-JSON-Core.package/Dictionary.extension/instance/neoJsonOn..st +++ b/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/instance/neoJsonOn..st @@ -1,3 +1,3 @@ -*neo-json-core +*neo-json-pharo-core neoJsonOn: neoJSONWriter neoJSONWriter writeMap: self \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/properties.json b/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/properties.json new file mode 100644 index 0000000..63f7607 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Core.package/OrderedDictionary.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "OrderedDictionary" } diff --git a/filetree/Neo-JSON-Pharo-Core.package/SmallDictionary.extension/instance/neoJsonOn..st b/filetree/Neo-JSON-Pharo-Core.package/SmallDictionary.extension/instance/neoJsonOn..st new file mode 100644 index 0000000..61a9c65 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Core.package/SmallDictionary.extension/instance/neoJsonOn..st @@ -0,0 +1,3 @@ +*neo-json-pharo-core +neoJsonOn: neoJSONWriter + neoJSONWriter writeMap: self \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Core.package/SmallDictionary.extension/properties.json b/filetree/Neo-JSON-Pharo-Core.package/SmallDictionary.extension/properties.json new file mode 100644 index 0000000..b852ddc --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Core.package/SmallDictionary.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "SmallDictionary" } + diff --git a/filetree/Neo-JSON-Pharo-Core.package/properties.json b/filetree/Neo-JSON-Pharo-Core.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Core.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/.filetree b/filetree/Neo-JSON-Pharo-Examples.package/.filetree new file mode 100644 index 0000000..8998102 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/repository/Neo-JSON-Core.package/monticello.meta/initializers.st b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/README.md similarity index 100% rename from repository/Neo-JSON-Core.package/monticello.meta/initializers.st rename to filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/README.md diff --git a/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/instance/fileName..st b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/instance/fileName..st new file mode 100644 index 0000000..3966e08 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/instance/fileName..st @@ -0,0 +1,3 @@ +accessing +fileName: anObject + fileName := anObject \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/instance/url..st b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/instance/url..st new file mode 100644 index 0000000..ca05f95 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/instance/url..st @@ -0,0 +1,3 @@ +accessing +url: anObject + url := anObject \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/properties.json b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/properties.json new file mode 100644 index 0000000..2b7c07f --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/Attachment.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "Neo-JSON-Pharo-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "url", + "fileName" ], + "name" : "Attachment", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/Neo-JSON-Tests.package/monticello.meta/initializers.st b/filetree/Neo-JSON-Pharo-Examples.package/BittrexResponse.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/monticello.meta/initializers.st rename to filetree/Neo-JSON-Pharo-Examples.package/BittrexResponse.class/README.md diff --git a/filetree/Neo-JSON-Pharo-Examples.package/BittrexResponse.class/properties.json b/filetree/Neo-JSON-Pharo-Examples.package/BittrexResponse.class/properties.json new file mode 100644 index 0000000..10c13ec --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/BittrexResponse.class/properties.json @@ -0,0 +1,16 @@ +{ + "category" : "Neo-JSON-Pharo-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "success", + "message", + "result" ], + "name" : "BittrexResponse", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Pharo-Examples.package/Market.class/README.md b/filetree/Neo-JSON-Pharo-Examples.package/Market.class/README.md new file mode 100644 index 0000000..e69de29 diff --git a/filetree/Neo-JSON-Pharo-Examples.package/Market.class/properties.json b/filetree/Neo-JSON-Pharo-Examples.package/Market.class/properties.json new file mode 100644 index 0000000..12a8842 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/Market.class/properties.json @@ -0,0 +1,24 @@ +{ + "category" : "Neo-JSON-Pharo-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "MarketCurrency", + "BaseCurrency", + "MarketCurrencyLong", + "BaseCurrencyLong", + "MinTradeSize", + "MarketName", + "IsActive", + "Created", + "Notice", + "IsSponsored", + "LogoUrl" ], + "name" : "Market", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/README.md b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/README.md new file mode 100644 index 0000000..e69de29 diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testAccessingTheNewYorkPublicLibrary.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testAccessingTheNewYorkPublicLibrary.st new file mode 100644 index 0000000..5ba6501 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testAccessingTheNewYorkPublicLibrary.st @@ -0,0 +1,13 @@ +tests +testAccessingTheNewYorkPublicLibrary + + | client reader data networkStream | + (client := ZnClient new) + streaming: true; + url: 'https://github.com/NYPL-publicdomain/data-and-utilities/blob/master/items/pd_items_1.ndjson?raw=true'; + get. + networkStream := ZnCharacterReadStream on: client contents. + reader := NeoJSONReader on: networkStream. + data := Array streamContents: [ :out | [ reader atEnd ] whileFalse: [ out nextPut: reader next ] ]. + client close. + data \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testAttachmentsExample.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testAttachmentsExample.st new file mode 100644 index 0000000..8ded541 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testAttachmentsExample.st @@ -0,0 +1,31 @@ +tests +testAttachmentsExample + | collectionOne json | + "Let's create a collection of two instances:" + collectionOne := {(Attachment new + url: 'http://example.com/random-name.txt' asZnUrl; + fileName: 'chapter-one.txt' yourself). + (Attachment new + url: 'http://example.com/random-name.png' asZnUrl; + fileName: 'image.png'; + yourself)}. + + "And let's map it to a JSON structure:" + json := String + streamContents: [ :aStream | + (NeoJSONWriter on: aStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + mapAllInstVarsFor: Attachment; + for: ZnUrl customDo: [ :mapping | mapping encoder: [ :aZnUrl | aZnUrl asString ] ]; + nextPut: collectionOne as: #CollectionOfAttachments ]. + + + "And read the JSON structure:" + (NeoJSONReader on: json readStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + for: Attachment + do: [ :mapping | + mapping mapInstVar: 'fileName'. + (mapping mapInstVar: 'url') valueSchema: ZnUrl ]; + for: ZnUrl customDo: [ :mapping | mapping decoder: [ :string | string asZnUrl ] ]; + nextAs: #CollectionOfAttachments \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDictionary.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDictionary.st new file mode 100644 index 0000000..82b469f --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDictionary.st @@ -0,0 +1,10 @@ +tests +testBittrexLitecoinAsDictionary + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarketSummary?market=BTC-LTC'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader next ]; + get. + \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDomainObjects.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDomainObjects.st new file mode 100644 index 0000000..f41da9c --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testBittrexLitecoinAsDomainObjects.st @@ -0,0 +1,16 @@ +tests +testBittrexLitecoinAsDomainObjects + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarkets'; + enforceHttpSuccess: true; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader for: BittrexResponse do: [:m| + m mapInstVar: #success. + m mapInstVar: #message. + (m mapInstVar: #result) valueSchema: #ArrayOfMarkets]. + reader for: #ArrayOfMarkets customDo: [ :mapping | mapping listOfElementSchema: Market ]. + reader mapInstVarsFor: Market. + reader nextAs: BittrexResponse ]; + get \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testDoomtownDBCards.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testDoomtownDBCards.st new file mode 100644 index 0000000..41531e4 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testDoomtownDBCards.st @@ -0,0 +1,4 @@ +tests +testDoomtownDBCards + + NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testFeed.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testFeed.st new file mode 100644 index 0000000..476852d --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testFeed.st @@ -0,0 +1,12 @@ +tests +testFeed + | json | + json := ZnClient new + systemPolicy; + url: 'https://daringfireball.net/feeds/json'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | NeoJSONObject fromString: entity contents ]; + get. + json items collect: #title. + json items collect: [ :each | each title -> each url ]. + json \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testGetWorldCapitals.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testGetWorldCapitals.st new file mode 100644 index 0000000..1fe53f1 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testGetWorldCapitals.st @@ -0,0 +1,4 @@ +tests +testGetWorldCapitals + ((NeoJSONReader fromString: (ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) + collect: [ :d | d at: #capital ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testGoogleMapsAPI.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testGoogleMapsAPI.st new file mode 100644 index 0000000..85bb04c --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testGoogleMapsAPI.st @@ -0,0 +1,7 @@ +tests +testGoogleMapsAPI + + ZnClient new + url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testParsingUserAgentStrings.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testParsingUserAgentStrings.st new file mode 100644 index 0000000..440e03f --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testParsingUserAgentStrings.st @@ -0,0 +1,9 @@ +tests +testParsingUserAgentStrings + ZnClient new + http; + host: 'useragentstring.com'; + queryAt: 'uas' put: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4'; + queryAt: 'getJSON' put: 'all'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testStackOverflowInfo.st b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testStackOverflowInfo.st new file mode 100644 index 0000000..645a79f --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/instance/testStackOverflowInfo.st @@ -0,0 +1,6 @@ +tests +testStackOverflowInfo + + ZnClient new + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get: 'http://api.stackexchange.com/2.1/info?site=stackoverflow' \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/properties.json b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/properties.json new file mode 100644 index 0000000..1fab219 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/NeoJSONPharoExamples.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Pharo-Examples", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONPharoExamples", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Pharo-Examples.package/properties.json b/filetree/Neo-JSON-Pharo-Examples.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Examples.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/filetree/Neo-JSON-Pharo-Tests.package/.filetree b/filetree/Neo-JSON-Pharo-Tests.package/.filetree new file mode 100644 index 0000000..8998102 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Tests.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/filetree/Neo-JSON-Pharo-Tests.package/properties.json b/filetree/Neo-JSON-Pharo-Tests.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-Pharo-Tests.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/.filetree b/filetree/Neo-JSON-Tests.package/.filetree new file mode 100644 index 0000000..8998102 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/initialize.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/initialize.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/initialize.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/initialize.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/read.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/read.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/read.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/read.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/write.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/write.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/write.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/write.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/writePrettyPrintedRead.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/writePrettyPrintedRead.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/writePrettyPrintedRead.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/instance/writePrettyPrintedRead.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/properties.json similarity index 79% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/properties.json index 99b98a0..1310fb1 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmark.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 6/5/2012 09:48", + "commentStamp" : "", "instvars" : [ "objects", "json" ], diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testObject2.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testObject2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testObject2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testObject2.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testPrettyPrinted.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testPrettyPrinted.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testPrettyPrinted.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testPrettyPrinted.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testRead.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testRead.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testRead.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testRead.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testWrite.st b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testWrite.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testWrite.st rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/instance/testWrite.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/properties.json similarity index 78% rename from repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/properties.json index 384696e..7bb4537 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 6/5/2012 10:05", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONBenchmarkTests", diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/README.md new file mode 100644 index 0000000..beb1b09 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/README.md @@ -0,0 +1 @@ +NeoJSONExamplesTests runs a couple of examples as tests \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testMultiInstances.st b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testMultiInstances.st new file mode 100644 index 0000000..296b4e0 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testMultiInstances.st @@ -0,0 +1,17 @@ +tests +testMultiInstances + "Newline delimited JSON (application/x-ndjson) - https://github.com/ndjson/ndjson-spec" + "JSON Lines (application/jsonl) - https://jsonlines.org" + + | data json | + + data := (1 to: 10) collect: [ :each | + { 'number' -> each } asDictionary ]. + + json := String streamContents: [ :out | + (NeoJSONWriter on: out) nextPutAll: data ]. + + self assert: (NeoJSONReader on: json readStream) upToEnd equals: data. + + self assert: (NeoJSONReader on: json readStream) next equals: data first. + self deny: ((NeoJSONReader on: json readStream) next; atEnd) \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testPoints.st b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testPoints.st new file mode 100644 index 0000000..9a85d33 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testPoints.st @@ -0,0 +1,33 @@ +tests +testPoints + | points json result | + + points := Array with: 1@2 with: 3@4 with: 5@6. + + json := String streamContents: [ :out | + (NeoJSONWriter on: out) + prettyPrint: true; + mapInstVarsFor: Point; + nextPut: points ]. + + result := (NeoJSONReader on: json readStream) + mapInstVarsFor: Point; + for: #ListOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]; + nextAs: #ListOfPoints. + + self assert: result equals: points. + + result := (NeoJSONReader on: json readStream) + mapInstVarsFor: Point; + nextListAs: Point. + + self assert: result equals: points. + + result := (NeoJSONReader on: json readStream) + mapInstVarsFor: Point; + for: #OrderedCollectionOfPoints customDo: [ :mapping | + mapping listOfType: OrderedCollection andElementSchema: Point ]; + nextAs: #OrderedCollectionOfPoints. + + self assert: result equals: points asOrderedCollection. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testRectanglePoints.st b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testRectanglePoints.st new file mode 100644 index 0000000..76cc28e --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testRectanglePoints.st @@ -0,0 +1,29 @@ +tests +testRectanglePoints + | rectangle rectangleJson result | + + rectangle := Rectangle origin: 3 @ 4 extent: 5 @ 6. + + rectangleJson := String streamContents: [ :stream | + (NeoJSONWriter on: stream) + prettyPrint: true; + mapInstVarsFor: Point; + mapInstVarsFor: Rectangle; + nextPut: rectangle ]. + + result := (NeoJSONReader on: rectangleJson readStream) + mapInstVarsFor: Point; + for: Rectangle do: [ :mapping | + (mapping mapInstVar: #origin) valueSchema: Point. + (mapping mapInstVar: #corner) valueSchema: Point ]; + nextAs: Rectangle. + + self assert: result equals: rectangle. + + result := (NeoJSONReader on: rectangleJson readStream) + mapInstVarsFor: Point; + for: Rectangle do: [ :mapping | + mapping mapInstVars do: [ :each | each valueSchema: Point ] ]; + nextAs: Rectangle. + + self assert: result equals: rectangle \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testRectanglePointsWithNils.st b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testRectanglePointsWithNils.st new file mode 100644 index 0000000..7011122 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/instance/testRectanglePointsWithNils.st @@ -0,0 +1,23 @@ +tests +testRectanglePointsWithNils + self + assert: + (String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Point do: [ :mapping | mapping mapAllInstVars ]; + for: Rectangle do: [ :mapping | + (mapping mapInstVar: #origin) valueSchema: Point. + (mapping mapInstVar: #corner) valueSchema: Point ]; + nextPut: Rectangle new ]) + equals: '{}'. + self + assert: + (String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Point do: [ :mapping | mapping mapAllInstVars ]; + for: Rectangle do: [ :mapping | + (mapping mapInstVar: #origin) valueSchema: Point. + (mapping mapInstVar: #corner) valueSchema: Point ]; + writeNil: true; + nextPut: Rectangle new ]) + equals: '{"origin":null,"corner":null}'. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/properties.json new file mode 100644 index 0000000..16c0d2d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONExamplesTests.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONExamplesTests", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/README.md new file mode 100644 index 0000000..14f4b03 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/README.md @@ -0,0 +1 @@ +I am NeoJSONFloatPrinterTests, the collection of unit tests for NeoJSONFloatPrinter. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/setUp.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/setUp.st new file mode 100644 index 0000000..ea65805 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/setUp.st @@ -0,0 +1,4 @@ +running +setUp + super setUp. + printer := NeoJSONFloatPrinter new \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testDecimalNotation.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testDecimalNotation.st new file mode 100644 index 0000000..df94892 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testDecimalNotation.st @@ -0,0 +1,14 @@ +tests +testDecimalNotation + self assert: (printer print: 1.5) equals: '1.5'. + self assert: (printer print: -1.5) equals: '-1.5'. + self assert: (printer print: 0.5) equals: '0.5'. + self assert: (printer print: -0.5) equals: '-0.5'. + self assert: (printer print: (1/3) asFloat) equals: '0.33333'. + self assert: (printer print: (-1/3) asFloat) equals: '-0.33333'. + self assert: (printer print: 0.00123) equals: '0.00123'. + self assert: (printer print: -0.00123) equals: '-0.00123'. + self assert: (printer print: 0.00012) equals: '0.00012'. + self assert: (printer print: -0.00012) equals: '-0.00012'. + self assert: (printer print: 123456.12345) equals: '123456.12345'. + self assert: (printer print: -123456.12345) equals: '-123456.12345'. diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testInteger.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testInteger.st new file mode 100644 index 0000000..58f95de --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testInteger.st @@ -0,0 +1,8 @@ +tests +testInteger + self assert: (printer print: 1.0) equals: '1'. + self assert: (printer print: 0.0) equals: '0'. + self assert: (printer print: -1.0) equals: '-1'. + self assert: (printer print: 123.0) equals: '123'. + self assert: (printer print: 123456.0) equals: '123456'. + \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testLowPrecision.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testLowPrecision.st new file mode 100644 index 0000000..9893809 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testLowPrecision.st @@ -0,0 +1,12 @@ +tests +testLowPrecision + printer := NeoJSONFloatPrinter lowPrecision. + self assert: (printer print: (4/3) asFloat) equals: '1.33'. + self assert: (printer print: 12345.66) equals: '12345.66'. + self assert: (printer print: -123456.77) equals: '-1.23e5'. + self assert: (printer print: Float pi) equals: '3.14'. + self assert: (printer print: Float e negated) equals: '-2.72'. + "the earth's mass in kg" + self assert: (printer print: 5.9724e24) equals: '5.97e24'. + "mass of electron in kg" + self assert: (printer print: 9.10938356e-31) equals: '9.11e-31'. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testScientificNotation.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testScientificNotation.st new file mode 100644 index 0000000..2263741 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testScientificNotation.st @@ -0,0 +1,6 @@ +tests +testScientificNotation + self assert: (printer print: 1234567.5) equals: '1.23457e6'. "note the rounding" + self assert: (printer print: -1234567.5) equals: '-1.23457e6'. "note the rounding" + self assert: (printer print: 0.0000123) equals: '1.23e-5'. + self assert: (printer print: -0.0000123) equals: '-1.23e-5'. diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testScientificOnly.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testScientificOnly.st new file mode 100644 index 0000000..7516ad9 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testScientificOnly.st @@ -0,0 +1,11 @@ +tests +testScientificOnly + printer := NeoJSONFloatPrinter scientificOnly. + self assert: (printer print: (4/3) asFloat) equals: '1.33333e0'. + self assert: (printer print: 12345.66) equals: '1.23457e4'. + self assert: (printer print: Float pi) equals: '3.14159e0'. + self assert: (printer print: Float e negated) equals: '-2.71828e0'. + "the earth's mass in kg" + self assert: (printer print: 5.9724e24) equals: '5.9724e24'. + "mass of electron in kg" + self assert: (printer print: 9.10938356e-31) equals: '9.10938e-31'. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testSpecialValues.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testSpecialValues.st new file mode 100644 index 0000000..5bbee9f --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testSpecialValues.st @@ -0,0 +1,6 @@ +tests +testSpecialValues + self assert: (printer print: Float zero) equals: '0'. + self assert: (printer print: Float nan) equals: 'NaN'. + self assert: (printer print: Float infinity) equals: 'Inf'. + self assert: (printer print: Float infinity negated) equals: '-Inf'. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testWellKnownConstants.st b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testWellKnownConstants.st new file mode 100644 index 0000000..12ede4d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/instance/testWellKnownConstants.st @@ -0,0 +1,16 @@ +tests +testWellKnownConstants + self assert: (printer print: Float pi) equals: '3.14159'. + self assert: (printer print: Float e) equals: '2.71828'. + "the earth's mass in kg" + self assert: (printer print: 5.9724e24) equals: '5.9724e24'. + "mass of electron in kg" + self assert: (printer print: 9.10938356e-31) equals: '9.10938e-31'. + "planck's constant in Js" + self assert: (printer print: 1.05457e-34) equals: '1.05457e-34'. + "speed of light in m/s" + self assert: (printer print: 2.99792e8) equals: '2.99792e8'. + "charge of electron in C" + self assert: (printer print: -1.60218e-19) equals: '-1.60218e-19'. + "boltzmann's constant in J/K" + self assert: (printer print: 1.38065e-23) equals: '1.38065e-23'. diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/properties.json new file mode 100644 index 0000000..96682a8 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONFloatPrinterTests.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "printer" ], + "name" : "NeoJSONFloatPrinterTests", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/README.md new file mode 100644 index 0000000..0247a5d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/README.md @@ -0,0 +1 @@ +I am NeoJSONMappingTests, testing more exotic kinds of mapping constructs. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testDynamicTyping.st b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testDynamicTyping.st new file mode 100644 index 0000000..b42066a --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testDynamicTyping.st @@ -0,0 +1,25 @@ +testing +testDynamicTyping + | data customMapping json result | + data := Array with: 'foo'->1 with: #('foo' 2). + "The idea is to map a key value combination as either a classic association or a simple pair, + using key & value properties as well as a type property to distinguish between the two" + customMapping := [ :mapper | + mapper + for: #AssocOrPair customDo: [ :mapping | + mapping + encoder: [ :x | + x isArray + ifTrue: [ Dictionary new at: 'type' put: 'pair'; at: 'key' put: x first; at: 'value' put: x second; yourself ] + ifFalse: [ Dictionary new at: 'type' put: 'assoc'; at: 'key' put: x key; at: 'value' put: x value; yourself ] ]; + decoder: [ :x | + (x at: 'type') = 'pair' + ifTrue: [ Array with: (x at: 'key') with: (x at: 'value') ] + ifFalse: [ (x at: 'key') -> (x at: 'value')] ] ]; + for: #ArrayOfAssocOrPair customDo: [ :mapping | + mapping listOfType: Array andElementSchema: #AssocOrPair ]; + yourself ]. + json := String streamContents: [ :out | + (customMapping value: (NeoJSONWriter on: out)) nextPut: data as: #ArrayOfAssocOrPair ]. + result := (customMapping value: (NeoJSONReader on: json readStream)) nextAs: #ArrayOfAssocOrPair. + self assert: result equals: data \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testSymbolOrStringInstVarMapping.st b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testSymbolOrStringInstVarMapping.st new file mode 100644 index 0000000..cb8d8b9 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testSymbolOrStringInstVarMapping.st @@ -0,0 +1,20 @@ +testing +testSymbolOrStringInstVarMapping + | data out1 out2 result1 result2 | + data := Array with: 1@2 with: 3@4. + out1 := String streamContents: [ :out | + (NeoJSONWriter on: out) + for: Point do: [ :mapping | mapping mapInstVars: #(x y) ]; + nextPut: data ]. + result1 := (NeoJSONReader on: out1 readStream) + for: Point do: [ :mapping | mapping mapInstVars: #(x y) ]; + nextListAs: Point. + self assert: result1 equals: data. + out2 := String streamContents: [ :out | + (NeoJSONWriter on: out) + for: Point do: [ :mapping | mapping mapInstVars: #('x' 'y') ]; + nextPut: data ]. + result2 := (NeoJSONReader on: out1 readStream) + for: Point do: [ :mapping | mapping mapInstVars: #('x' 'y') ]; + nextListAs: Point. + self assert: result2 equals: data \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testVirtualTransferObject.st b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testVirtualTransferObject.st new file mode 100644 index 0000000..7a8713c --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/instance/testVirtualTransferObject.st @@ -0,0 +1,27 @@ +testing +testVirtualTransferObject + | data customMapping extraJson json result | + data := NeoJSONObject new data: (Array with: 1@1 with: 2@2). + extraJson := '{"foo":1,"data":[{"x":1,"y":1},{"x":2,"y":2,"z":-1}]}'. + "The idea here is that we are not interested in the top level object just in its data property, + which should be of a specific type, hence we create a virtual transfer object" + customMapping := [ :mapper | + mapper + for: Point do: [ :mapping | + mapping mapInstVars: #(x y) ]; + for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]; + for: #TransferObject do: [ :mapping | + mapping subjectClass: NeoJSONObject. + (mapping mapAccessor: #data) valueSchema: #ArrayOfPoints ]; + yourself ]. + "By using NeoJSONObject accessors (#data & #data:) are translated to generic #at:[put:] messages. + A longer alternative is + (mapping mapProperty: #data getter: [ :obj | obj at: #data ] setter: [ :obj :x | obj at: #data put: x]) valueSchema: #ArrayOfPoints + where the blocks give you the flexibility to use a plain Dictionary for example" + result := (customMapping value: (NeoJSONReader on: extraJson readStream)) nextAs: #TransferObject. + self assert: result equals: data. + json := String streamContents: [ :out | + (customMapping value: (NeoJSONWriter on: out)) nextPut: data as: #TransferObject ]. + result := (customMapping value: (NeoJSONReader on: json readStream)) nextAs: #TransferObject. + self assert: result equals: data \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/properties.json new file mode 100644 index 0000000..deb4b74 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMappingTests.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONMappingTests", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/class/on..st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/class/on..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/class/on..st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/class/on..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/atEnd.st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/atEnd.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/atEnd.st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/atEnd.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/close.st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/close.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/close.st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/close.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/collectionSpecies.st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/collectionSpecies.st new file mode 100644 index 0000000..1020191 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/collectionSpecies.st @@ -0,0 +1,3 @@ +accessing +collectionSpecies + ^ stream collectionSpecies \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/next.st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/next.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/next.st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/next.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPut..st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPut..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPut..st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPut..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPutAll..st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPutAll..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPutAll..st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/nextPutAll..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peek.st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peek.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peek.st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peek.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peekFor..st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peekFor..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peekFor..st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/peekFor..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/space.st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/space.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/space.st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/space.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/stream..st b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/stream..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/stream..st rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/instance/stream..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/properties.json similarity index 85% rename from repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/properties.json index 733f178..e4f0993 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONMockStream.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "stream" ], "name" : "NeoJSONMockStream", diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/README.md new file mode 100644 index 0000000..51b44cb --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/README.md @@ -0,0 +1 @@ +I am NeoJSONObjectTests, I hold unit tests for NeoJSONObject. diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/class/exampleJSONSchema.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/class/exampleJSONSchema.st new file mode 100644 index 0000000..b8dbd56 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/class/exampleJSONSchema.st @@ -0,0 +1,15 @@ +accessing +exampleJSONSchema + ^ NeoJSONObject fromString: '{ + "$id" : "https://example.com/schemas/address", + "type" : "object", + "properties" : { + "street_address" : { "$anchor" : "street_address", "type" : "string" }, + "city" : { "type" : "string" }, + "state" : { "type" : "string" } + }, + "required" : ["street_address", "city", "state"], + "$defs" : { + "country" : { "type" : "object", "$anchor" : "country", "enum" : ["us","canada","gb"] } + } +}' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testArray.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testArray.st new file mode 100644 index 0000000..aac1974 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testArray.st @@ -0,0 +1,14 @@ +testing +testArray + | jsonArray array | + jsonArray := '[-2,1,2,3]'. + array := NeoJSONObject fromString: jsonArray. + self assert: array asString equals: jsonArray. + + self assertCollection: array equals: (NeoJSONArray withAll: {-2. 1. 2. 3.}). + array at: -2 add: 0. + array at: #'-' add: 4. + self assertCollection: array equals: (NeoJSONArray withAll: {0. -2. 1. 2. 3. 4.}). + array removeKey: 6. + array removeKey: 1. + self assertCollection: array equals: (NeoJSONArray withAll: {-2. 1. 2. 3.}) \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtAt.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtAt.st new file mode 100644 index 0000000..a88112b --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtAt.st @@ -0,0 +1,13 @@ +testing +testAtAt + | object | + object := NeoJSONObject new. + self assert: (object at: #'foo') isNil. + self assert: (object at: #'foo' at: #'bar') isNil. + object at: #'foo' at: #'bar' put: 123. + self assert: (object at: #'foo') notNil. + self assert: (object at: #'foo' at: #'bar') equals: 123. + self assert: object foo bar equals: 123. + object at: #'foo' at: #'bar' put: -1. + self assert: (object at: #'foo' at: #'bar') equals: -1. + self assert: (object at: #'foo' at: #'foo') isNil \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtPath.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtPath.st new file mode 100644 index 0000000..c5196c2 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtPath.st @@ -0,0 +1,16 @@ +testing +testAtPath + | object | + object := NeoJSONObject newFrom: (Array with: #'one' -> (NeoJSONObject newFrom: (Array with: #'two' -> (NeoJSONObject newFrom: (Array with: #'three' -> 42))))). + self assert: (object atPath: #(#'one' #'two' #'three')) equals: 42. + self assert: (object atPath: #(#'one' #'two' #'three')) equals: object one two three. + self assert: (object atPath: #(#'missing')) equals: nil. + self assert: (object atPath: #(#'one' #'missing')) equals: nil. + self assert: (object atPath: #(#'one' #'two' #'missing')) equals: nil. + self assert: (object atPath: #(#'one' #'two' #'missing')) equals: object one two missing. + + object := NeoJSONObject newFrom: (Array with: #'foo' -> 42). + self assert: (object atPath: #(#'foo')) equals: 42. + self assert: (object atPath: #(#'foo')) equals: object foo. + self assert: (object atPath: #(#'foo')) equals: (object at: #'foo'). + self assert: (object atPath: #()) equals: object. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtPathPut.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtPathPut.st new file mode 100644 index 0000000..7f55e65 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testAtPathPut.st @@ -0,0 +1,19 @@ +testing +testAtPathPut + | object | + object := NeoJSONObject new. + object atPath: #(#'one' #'test') put: 42. + self assert: (object atPath: #(#'one' #'test')) equals: 42. + self assert: object one test equals: 42. + object atPath: #(#'one' #'two' #'three') put: #'foo'. + self assert: (object atPath: #(#'one' #'two' #'three')) equals: #'foo'. + self assert: object one two three equals: #'foo'. + object atPath: #(#'one' #'two' #'threeBis') put: #'bar'. + self assert: (object atPath: #(#'one' #'two' #'threeBis')) equals: #'bar'. + self assert: object one two threeBis equals: #'bar'. + + self assert: object foo isNil. + self assert: (object atPath: #() put: 1) equals: object. + self assert: (object atPath: #(#'foo') put: 1) equals: 1. + self assert: (object atPath: #(#'foo')) equals: 1. + self assert: object foo equals: 1 \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testCRUD.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testCRUD.st new file mode 100644 index 0000000..51c3da0 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testCRUD.st @@ -0,0 +1,18 @@ +testing +testCRUD + | object | + object := NeoJSONObject new. + self assert: object isEmpty. + self assert: object foo equals: nil. + object foo: 123. + self assert: object foo equals: 123. + self assert: object printString equals: '{"foo":123}'. + object name: 'test'. + object value: Float pi. + self assert: object name equals: 'test'. + self assert: (object value closeTo: Float pi). + self assert: object keys asSet equals: #(#'foo' #'name' #'value') asSet. + object removeKey: #'foo'. + self assert: object foo equals: nil. + object removeAll. + self assert: object isEmpty \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPath.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPath.st new file mode 100644 index 0000000..a297d62 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPath.st @@ -0,0 +1,22 @@ +testing +testFindPath + | json path | + json := self class exampleJSONSchema. + + path := json findPath: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'street_address' ] ]. + self deny: path isNil. + self assert: path equals: #(properties street_address). + self assert: ((json atPath: path) at: #'$anchor') equals: 'street_address'. + + path := json findPath: [ :object | object isDictionary and: [ (object at: #'foo') = 'bar' ] ]. + self assert: path isNil. + + path := json findPath: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'country' ] ]. + self deny: path isNil. + self assert: path equals: #(#'$defs' #'country'). + self assert: ((json atPath: path) at: #'$anchor') equals: 'country'. + + json := NeoJSONObject new at: #'$anchor' put: 'top'; yourself. + self + assert: (json findPath: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'top' ] ]) + equals: #(()) \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st new file mode 100644 index 0000000..c25e3e9 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testFindPaths.st @@ -0,0 +1,26 @@ +testing +testFindPaths + | json paths testingArray | + json := self class exampleJSONSchema. + testingArray := #((#'properties' #'street_address') (#'$defs' #'country')). + + paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'$anchor' ] ]. + self deny: paths isEmpty. + (paths asArray) do: [ :eachArray | + self assert: (testingArray includes: eachArray) ]. + paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'street_address' ] ]. + self assert: (testingArray includes: paths flattened). + paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'$anchor') = 'country' ] ]. + self assert: (testingArray includes: paths flattened). + + paths := json findPaths: [ :object | object isDictionary and: [ (object at: #'foo') = 'bar' ] ]. + self assert: paths isEmpty. + + paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #'type' ] ]. + self deny: paths isEmpty. + paths do: [ :path | + self assert: (#('string' 'object') includes: ((json atPath: path) at: #'type')) ]. + + paths := json findPaths: [ :_ | true ]. + paths do: [ :each | + self assert: (json atPath: each) notNil ] diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testJSON.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testJSON.st new file mode 100644 index 0000000..0513aae --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testJSON.st @@ -0,0 +1,10 @@ +testing +testJSON + | data json object | + data := NeoJSONObject newFrom: (Array with: #'foo'->1 with: #'bar'->2 with: #'str'->'Str!' with: #'bool'->true with: #'flt'->1.5). + json := NeoJSONWriter toString: data . + object := NeoJSONObject fromString: json. + self assert: object class equals: NeoJSONObject. + self assert: object equals: data. + json := (NeoJSONWriter toString: object). + self assert: (NeoJSONObject fromString: json) equals: object \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testPathAccess.st b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testPathAccess.st new file mode 100644 index 0000000..655e410 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/instance/testPathAccess.st @@ -0,0 +1,20 @@ +testing +testPathAccess + | data | + data := NeoJSONObject fromString: '{"foo":1,"bar":2,"array":[{"a":1},{"b":2}]}'. + self assert: (data atPath: #(#'array' 1 #'a')) equals: 1. + self assert: (data atPath: #(#'array' 2 #'b')) equals: 2. + self assert: (data atPath: #(#'missing' 1)) equals: nil. + data atPath: #(#'missing') put: 7. + self assert: (data atPath: #(#'missing')) equals: 7. + self assert: (data atPath: #(#'array' 3)) equals: nil. + data := NeoJSONObject fromString: '[{"c":1},{"c":2},{"c":3}]'. + self assert: (data atPath: #(2 #'c')) equals: 2. + self assert: (data atPath: #(10 #'c')) equals: nil. + self assert: (data atPath: #(3 #'missing')) equals: nil. + data atPath: #(3 #'missing') put: #found. + self assert: (data atPath: #(3 #'missing')) equals: #found. + (data at: 3) removeKey: #missing. + self assert: (data atPath: #(3 #'missing')) equals: nil. + data atPath: #(3 #'missing' #'x') put: #found. + self assert: (data atPath: #(3 #'missing' #'x')) equals: #found. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/properties.json new file mode 100644 index 0000000..d35cb6d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONObjectTests.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONObjectTests", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/README.md diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAllowNil.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAllowNil.st new file mode 100644 index 0000000..5c19107 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAllowNil.st @@ -0,0 +1,21 @@ +testing +testAllowNil + self + should: [ + (NeoJSONReader on: 'null' readStream) + mapInstVarsFor: Point; + nextAs: Point ] + raise: NeoJSONParseError. + self + assert: ((NeoJSONReader on: 'null' readStream) + mapInstVarsFor: Point; + for: Point do: [ :mapping | mapping allowNil ]; + nextAs: Point) + equals: nil. + self + assert: ((NeoJSONReader on: '[ { "x" : 1, "y" : 2 }, null, { "x" : 3, "y" : -1 } ]' readStream) + mapInstVarsFor: Point; + for: Point do: [ :mapping | mapping allowNil ]; + for: #ArrayOfPoints customDo: [ :mapping | mapping listOfElementSchema: Point ]; + nextAs: #ArrayOfPoints) + equals: (Array with: 1 @ 2 with: nil with: 3 @ -1). \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPoints.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPoints.st similarity index 76% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPoints.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPoints.st index 7e8d745..699f257 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPoints.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPoints.st @@ -8,6 +8,6 @@ testArrayOfPoints for: #ArrayOfPoints customDo: [ :mapping | mapping listOfElementSchema: Point ]; nextAs: #ArrayOfPoints ]. - self assert: (reader value: '[ { "x":1, "y":2 }, { "x":-1, "y":-2 } ]') equals: { 1@2. -1@ -2 }. + self assert: (reader value: '[ { "x":1, "y":2 }, { "x":-1, "y":-2 } ]') equals: (Array with: 1@2 with: -1@ -2) . self assert: (reader value: '[ ]') equals: #(). - self assert: (reader value: '[ { } ]') equals: { Point new } \ No newline at end of file + self assert: (reader value: '[ { } ]') equals: (Array with: Point new) \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPointsUsingNextListAs.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPointsUsingNextListAs.st new file mode 100644 index 0000000..8415dea --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testArrayOfPointsUsingNextListAs.st @@ -0,0 +1,10 @@ +testing +testArrayOfPointsUsingNextListAs + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + mapInstVarsFor: Point; + nextListAs: Point ]. + self assert: (reader value: '[ { "x":1, "y":2 }, { "y":-2, "x":-1 } ]') equals: (Array with: 1@2 with: -1@ -2) . + self assert: (reader value: '[ ]') equals: #(). + self assert: (reader value: '[ { } ]') equals: (Array with: Point new) \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAssociation.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAssociation.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAssociation.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testAssociation.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testBooleans.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testBooleans.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testBooleans.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testBooleans.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testByteArray.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testByteArray.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testByteArray.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testByteArray.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDate.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDate.st similarity index 89% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDate.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDate.st index 2bbaf22..752c865 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDate.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDate.st @@ -6,4 +6,4 @@ testDate for: Date customDo: [ :mapping | mapping decoder: [ :string | (DateAndTime fromString: string) asDate ] ]; nextAs: Date ]. - self assert: (reader value: ' "2012-06-08" ') equals: (Date newDay: 8 month: 'June' year: 2012) \ No newline at end of file + self assert: (reader value: ' "2012-06-08" ') equals: (Date newDay: 8 month: 'June' year: 2012) diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDateAndTime.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDateAndTime.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDateAndTime.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testDateAndTime.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testFloats.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testFloats.st similarity index 93% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testFloats.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testFloats.st index 771f131..1dc3abd 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testFloats.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testFloats.st @@ -16,7 +16,7 @@ testFloats self assert: ((reader value: '-123e-6') closeTo: -123e-6). self assert: ((reader value: '-123E6') closeTo: -123e6). self assert: ((reader value: '-123E-6') closeTo: -123e-6). - self assert: ((reader value: '3.14159') closeTo: Float pi). + self assert: ((reader value: '3.141592653589793') closeTo: Float pi). self assert: ((reader value: '0.123e6') closeTo: 0.123e6). self assert: ((reader value: '0.123e-6') closeTo: 0.123e-6). self assert: ((reader value: '-0.123E6') closeTo: -0.123e6). diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testIntegers.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testIntegers.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testIntegers.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testIntegers.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testLists.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testLists.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testLists.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testLists.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testMaps.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testMaps.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testMaps.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testMaps.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNextStringAsHex.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNextStringAsHex.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNextStringAsHex.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNextStringAsHex.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNonBMPCharacterDecoding.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNonBMPCharacterDecoding.st new file mode 100644 index 0000000..1e578d6 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNonBMPCharacterDecoding.st @@ -0,0 +1,11 @@ +testing +testNonBMPCharacterDecoding + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + + | string object | + string := 16r1D11E asCharacter asString. "MUSICAL SYMBOL G CLEF" + object := (NeoJSONReader fromString: '"\uD834\uDD1E"'). + self assert: object equals: string. + + "UTF-16 surrogate pairs might be invalid, make sure an error is raised" + self should: [ NeoJSONReader fromString: '"\udbff\ue000"' ] raise: NeoJSONParseError \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNull.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNull.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNull.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testNull.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollection.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollection.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollection.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollection.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollectionOfPoints.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollectionOfPoints.st similarity index 88% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollectionOfPoints.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollectionOfPoints.st index 8a1f6a7..10317dc 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollectionOfPoints.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testOrderedCollectionOfPoints.st @@ -8,6 +8,6 @@ testOrderedCollectionOfPoints for: #OrderedCollectionOfPoints customDo: [ :mapping | mapping listOfType: OrderedCollection andElementSchema: Point ]; nextAs: #OrderedCollectionOfPoints ]. - self assert: (reader value: '[ { "x":1, "y":2 }, { "x":-1, "y":-2 } ]') equals: { 1@2. -1@ -2 } asOrderedCollection. + self assert: (reader value: '[ { "x":1, "y":2 }, { "x":-1, "y":-2 } ]') equals: (Array with: 1@2 with: -1@ -2) asOrderedCollection. self assert: (reader value: '[ ]') equals: OrderedCollection new. self assert: (reader value: '[ { } ]') equals: (OrderedCollection with: Point new) \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testParseErrors.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testParseErrors.st new file mode 100644 index 0000000..678f055 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testParseErrors.st @@ -0,0 +1,9 @@ +testing +testParseErrors + self should: [ NeoJSONReader fromString: 'zero' ] raise: NeoJSONParseError. + self should: [ NeoJSONReader fromString: '#' ] raise: NeoJSONParseError. + self should: [ NeoJSONReader fromString: '@' ] raise: NeoJSONParseError. + + self should: [ (NeoJSONReader on: '[1,2,3]true' readStream) next; failIfNotAtEnd ] raise: NeoJSONParseError. + self should: [ (NeoJSONReader on: '{"foo":1}"extra"' readStream) next; failIfNotAtEnd ] raise: NeoJSONParseError. + self should: [ (NeoJSONReader on: '[]"extra"' readStream) next; failIfNotAtEnd ] raise: NeoJSONParseError. \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint1.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint1.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint1.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint2.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint2.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint3.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint3.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint3.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPoint3.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPointUsingAsString.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPointUsingAsString.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPointUsingAsString.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPointUsingAsString.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPropertyNamesAsSymbols.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPropertyNamesAsSymbols.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPropertyNamesAsSymbols.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testPropertyNamesAsSymbols.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSmallDictionary.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSmallDictionary.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSmallDictionary.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSmallDictionary.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testStrings.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testStrings.st new file mode 100644 index 0000000..ce009e2 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testStrings.st @@ -0,0 +1,27 @@ +testing +testStrings + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) next ]. + self assert: (reader value: '"foo"') equals: 'foo'. + self assert: (reader value: '""') equals: ''. + self assert: (reader value: '"Foo BAR"') equals: 'Foo BAR'. + self assert: (reader value: '" foo "') equals: ' foo '. + self assert: (reader value: '"\u00E9l\u00E8ve en Fran\u00E7ais"') equals: 'élève en Français'. + self + assert: (reader value: '"\"\\\/\t\r\n\f\b"') + equals: (String withAll: ( OrderedCollection new + add: $"; + add: $\; + add: $/; + add: Character tab; + add: Character cr; + add: Character lf; + add: Character newPage; + add: Character backspace; + yourself )). + self should: [ reader value: '"open' ] raise: NeoJSONParseError. + self should: [ reader value: '"\uAA"' ] raise: NeoJSONParseError. + self should: [ reader value: '"\uZZ"' ] raise: NeoJSONParseError. + self should: [ reader value: '"\x"' ] raise: NeoJSONParseError. + self should: [ reader value: ' " ' ] raise: NeoJSONParseError. diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSymbol.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSymbol.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSymbol.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testSymbol.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testTime.st b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testTime.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testTime.st rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testTime.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/properties.json similarity index 78% rename from repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/properties.json index c983efa..f3ec786 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONReaderTests.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 6/2/2012 14:02", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONReaderTests", diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/example1.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/example1.st similarity index 96% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/example1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/example1.st index bbf6cb8..0090a98 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/example1.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/example1.st @@ -16,4 +16,4 @@ example1 {(1 @ 2). (3 @ 4)}; bytes: #(2 4 6 8) asByteArray; - yourself \ No newline at end of file + yourself diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/neoJsonMapping..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/neoJsonMapping..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/neoJsonMapping..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/class/neoJsonMapping..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/^equals.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/^equals.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/^equals.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/^equals.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/bytes.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/hash.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/hash.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/hash.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/hash.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/id.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/name.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/points.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/instance/timestamp.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/properties.json similarity index 88% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/properties.json index 10fb964..43f3cb3 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject1.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "", + "commentStamp" : "", "instvars" : [ "id", "name", diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark..st similarity index 75% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark..st index 0792ae3..abb3c4b 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark..st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark..st @@ -7,10 +7,10 @@ benchmark: count size := 2 + (count * (NeoJSONWriter toString: self example1) size) + count - 1. Transcript cr; - << ('Serializing {1} objects took ms ' format: { count }); + << ('Serializing {1} objects took ms ' format: (Array with: count) ); show: [ json := String new: size streamContents: [ :stream | (NeoJSONWriter on: stream) nextPut: collection ] ] timeToRun. Transcript cr; - << ('Deserializing {1} objects took ms ' format: { count }); + << ('Deserializing {1} objects took ms ' format: (Array with: count) ); show: [ NeoJSONReader fromString: json ] timeToRun. \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10k.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10k.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10k.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10k.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10kAsDictionary.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10kAsDictionary.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10kAsDictionary.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark10kAsDictionary.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark200k.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark200k.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark200k.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmark200k.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmarkAsDictionary..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmarkAsDictionary..st similarity index 76% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmarkAsDictionary..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmarkAsDictionary..st index 20a9f20..38321d7 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmarkAsDictionary..st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/benchmarkAsDictionary..st @@ -7,10 +7,10 @@ benchmarkAsDictionary: count size := 2 + (count * (NeoJSONWriter toString: self example1 asDictionary) size) + count - 1. Transcript cr; - << ('Serializing {1} objects took ms ' format: { count }); + << ('Serializing {1} objects took ms ' format: (Array with: count) ); show: [ json := String new: size streamContents: [ :stream | (NeoJSONWriter on: stream) nextPut: collection ] ] timeToRun. Transcript cr; - << ('Deserializing {1} objects took ms ' format: { count }); + << ('Deserializing {1} objects took ms ' format: (Array with: count) ); show: [ NeoJSONReader fromString: json ] timeToRun. \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/example1.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/example1.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/example1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/example1.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/neoJsonMapping..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/neoJsonMapping..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/neoJsonMapping..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/class/neoJsonMapping..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/^equals.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/^equals.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/^equals.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/^equals.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/asDictionary.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/asDictionary.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/asDictionary.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/asDictionary.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/data.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/hash.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/hash.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/hash.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/hash.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/height.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/id.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/instance/width.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/properties.json similarity index 80% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/properties.json index 9dbc595..b5d9851 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject2.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 3/22/2014 09:36", + "commentStamp" : "", "instvars" : [ "id", "width", diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/example1.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/example1.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/example1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/example1.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/neoJsonMapping..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/neoJsonMapping..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/neoJsonMapping..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/class/neoJsonMapping..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/^equals.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/^equals.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/^equals.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/^equals.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/asDictionary.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/asDictionary.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/asDictionary.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/asDictionary.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/color.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent..st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent..st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent.st b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent.st rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/instance/transparent.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/properties.json similarity index 80% rename from repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/properties.json index 71cb921..b4f73aa 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONTestObject3.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 3/22/2014 09:40", + "commentStamp" : "", "instvars" : [ "color", "transparent" ], diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/README.md new file mode 100644 index 0000000..57e75e2 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/README.md @@ -0,0 +1,27 @@ +I am NeoJSONValidation, a set of tests to validate NeoJSON against some external rules. + +Both positive & negative tests are includes. +Some of these are implementation choices. + +http://seriot.ch/parsing_json.php +https://github.com/nst/JSONTestSuite +https://github.com/nst/JSONTestSuite.git + test_parsing + test_transform + +https://github.com/miloyip/nativejson-benchmark +https://github.com/miloyip/nativejson-benchmark.git + data/jsonchecker + data/roundtrip + +This can only be run with the correct setup (checkout/config). + + NeoJSONValidation new runNativeJsonBenchmarkRoundTrip. + NeoJSONValidation new runNativeJsonBenchmarkJsonCheckerPasses. + NeoJSONValidation new runNativeJsonBenchmarkJsonCheckerFailures. + + NeoJSONValidation new runJsonTestSuiteTestParsingPasses. + NeoJSONValidation new runJsonTestSuiteTestParsingFailures. + NeoJSONValidation new runJsonTestSuiteTestParsingInfo. + +Logging goes to a file, neo-json-validation.log \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/closeLog.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/closeLog.st new file mode 100644 index 0000000..7ceefa9 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/closeLog.st @@ -0,0 +1,8 @@ +private +closeLog + logStream ifNotNil: [ + logStream close. + logStream := nil ]. + ^ self logFile exists + ifTrue: [ self logFile contents ] + ifFalse: [ 'log file is empty' ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/ensureLog.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/ensureLog.st new file mode 100644 index 0000000..c8241d6 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/ensureLog.st @@ -0,0 +1,6 @@ +private +ensureLog + logStream ifNil: [ + logStream := self logFile ensureDelete; writeStream. + logStream setToEnd ] + \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/gitDirectory..st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/gitDirectory..st new file mode 100644 index 0000000..9325c2d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/gitDirectory..st @@ -0,0 +1,3 @@ +accessing +gitDirectory: fileReference + gitDirectory := fileReference \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/gitDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/gitDirectory.st new file mode 100644 index 0000000..34c0c12 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/gitDirectory.st @@ -0,0 +1,3 @@ +accessing +gitDirectory + ^ gitDirectory ifNil: [ gitDirectory := FileLocator home / #Develop / #git ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteDirectory.st new file mode 100644 index 0000000..e82a99d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteDirectory.st @@ -0,0 +1,3 @@ +accessing +jsonTestSuiteDirectory + ^ self gitDirectory / #JSONTestSuite \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingDirectory.st new file mode 100644 index 0000000..5a99df0 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingDirectory.st @@ -0,0 +1,3 @@ +accessing +jsonTestSuiteTestParsingDirectory + ^ self jsonTestSuiteDirectory / 'test_parsing' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingFailFiles.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingFailFiles.st new file mode 100644 index 0000000..7f4ef80 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingFailFiles.st @@ -0,0 +1,3 @@ +accessing +jsonTestSuiteTestParsingFailFiles + ^ self jsonTestSuiteTestParsingDirectory childrenMatching: 'n_*.json' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingInfoFiles.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingInfoFiles.st new file mode 100644 index 0000000..64c9fb9 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingInfoFiles.st @@ -0,0 +1,3 @@ +accessing +jsonTestSuiteTestParsingInfoFiles + ^ self jsonTestSuiteTestParsingDirectory childrenMatching: 'i_*.json' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingPassFiles.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingPassFiles.st new file mode 100644 index 0000000..476bb03 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestParsingPassFiles.st @@ -0,0 +1,3 @@ +accessing +jsonTestSuiteTestParsingPassFiles + ^ self jsonTestSuiteTestParsingDirectory childrenMatching: 'y_*.json' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestTransformDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestTransformDirectory.st new file mode 100644 index 0000000..b9a0706 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/jsonTestSuiteTestTransformDirectory.st @@ -0,0 +1,3 @@ +accessing +jsonTestSuiteTestTransformDirectory + ^ self jsonTestSuiteDirectory / 'test_transform' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/log..st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/log..st new file mode 100644 index 0000000..6b806e5 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/log..st @@ -0,0 +1,4 @@ +private +log: message + self ensureLog. + logStream nextPutAll: message; lf; flush diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/logFile.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/logFile.st new file mode 100644 index 0000000..ba58e23 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/logFile.st @@ -0,0 +1,3 @@ +private +logFile + ^ 'neo-json-validation.log' asFileReference \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkDataDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkDataDirectory.st new file mode 100644 index 0000000..211be52 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkDataDirectory.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkDataDirectory + ^ self nativeJsonBenchmarkDirectory / #data \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkDirectory.st new file mode 100644 index 0000000..dd17440 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkDirectory.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkDirectory + ^ self gitDirectory / 'nativejson-benchmark' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerDirectory.st new file mode 100644 index 0000000..2bdf04c --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerDirectory.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkJsonCheckerDirectory + ^ self nativeJsonBenchmarkDataDirectory / #jsonchecker \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerFailFiles.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerFailFiles.st new file mode 100644 index 0000000..3b7a188 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerFailFiles.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkJsonCheckerFailFiles + ^ self nativeJsonBenchmarkJsonCheckerDirectory childrenMatching: 'fail*.json' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerPassFiles.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerPassFiles.st new file mode 100644 index 0000000..c1df699 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkJsonCheckerPassFiles.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkJsonCheckerPassFiles + ^ self nativeJsonBenchmarkJsonCheckerDirectory childrenMatching: 'pass*.json' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkRoundTripDirectory.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkRoundTripDirectory.st new file mode 100644 index 0000000..405b93b --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkRoundTripDirectory.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkRoundTripDirectory + ^ self nativeJsonBenchmarkDataDirectory / #roundtrip \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkRoundTripFiles.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkRoundTripFiles.st new file mode 100644 index 0000000..5029c8e --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/nativeJsonBenchmarkRoundTripFiles.st @@ -0,0 +1,3 @@ +accessing +nativeJsonBenchmarkRoundTripFiles + ^ self nativeJsonBenchmarkRoundTripDirectory children \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingFailures.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingFailures.st new file mode 100644 index 0000000..184c8f7 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingFailures.st @@ -0,0 +1,11 @@ +running +runJsonTestSuiteTestParsingFailures + ^ self + validateFiles: self jsonTestSuiteTestParsingFailFiles + usingTest: [ :file | + | data success | + success := false. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next; failIfNotAtEnd ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := true ]. + success ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingInfo.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingInfo.st new file mode 100644 index 0000000..f8455fb --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingInfo.st @@ -0,0 +1,11 @@ +running +runJsonTestSuiteTestParsingInfo + ^ self + validateFiles: self jsonTestSuiteTestParsingInfoFiles + usingTest: [ :file | + | data success | + success := true. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := false ]. + success ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingPasses.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingPasses.st new file mode 100644 index 0000000..b825c57 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runJsonTestSuiteTestParsingPasses.st @@ -0,0 +1,11 @@ +running +runJsonTestSuiteTestParsingPasses + ^ self + validateFiles: self jsonTestSuiteTestParsingPassFiles + usingTest: [ :file | + | data success | + success := true. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := false ]. + success ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkJsonCheckerFailures.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkJsonCheckerFailures.st new file mode 100644 index 0000000..cf2a3fb --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkJsonCheckerFailures.st @@ -0,0 +1,11 @@ +running +runNativeJsonBenchmarkJsonCheckerFailures + ^ self + validateFiles: self nativeJsonBenchmarkJsonCheckerFailFiles + usingTest: [ :file | + | data success | + success := false. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next; failIfNotAtEnd ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := true ]. + success ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkJsonCheckerPasses.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkJsonCheckerPasses.st new file mode 100644 index 0000000..dd7d42c --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkJsonCheckerPasses.st @@ -0,0 +1,11 @@ +running +runNativeJsonBenchmarkJsonCheckerPasses + ^ self + validateFiles: self nativeJsonBenchmarkJsonCheckerPassFiles + usingTest: [ :file | + | data success | + success := true. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := false ]. + success ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkRoundTrip.st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkRoundTrip.st new file mode 100644 index 0000000..945a380 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/runNativeJsonBenchmarkRoundTrip.st @@ -0,0 +1,9 @@ +running +runNativeJsonBenchmarkRoundTrip + ^ self + validateFiles: self nativeJsonBenchmarkRoundTripFiles + usingTest: [ :file | + | data json | + data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ]. + json := NeoJSONWriter toString: data. + json = file contents ] \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/validateFiles.usingTest..st b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/validateFiles.usingTest..st new file mode 100644 index 0000000..4411f84 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/instance/validateFiles.usingTest..st @@ -0,0 +1,18 @@ +private +validateFiles: files usingTest: block + | total succeeded failed | + total := succeeded := failed := 0. + files do: [ :file | + | success | + self log: 'Running ' , file pathString. + self log: ([ file contents contractTo: 64 ] on: Error do: [ :exception | exception printString ]). + success := [ block value: file ] + on: Error + do: [ :exception | self log: ' Errored. ' , exception printString. false ]. + total := total + 1. + success + ifTrue: [ succeeded := succeeded + 1 ] + ifFalse: [ failed := failed + 1 ]. + self log: (success ifTrue: [ ' Succeeded' ] ifFalse: [ ' Failed' ]); log: '' ]. + self log: ('{1} total = {2} succeeded + {3} failed' format: (Array with: total with: succeeded with: failed) ). + ^ self closeLog \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/properties.json new file mode 100644 index 0000000..475cf5c --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONValidation.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "Neo-JSON-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "gitDirectory", + "logStream" ], + "name" : "NeoJSONValidation", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/README.md new file mode 100644 index 0000000..f24c05e --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/README.md @@ -0,0 +1 @@ +I am NeoJSONWriteReadAsciiOnlyTests. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/instance/writeRead..st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/instance/writeRead..st new file mode 100644 index 0000000..3b0a09c --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/instance/writeRead..st @@ -0,0 +1,6 @@ +private +writeRead: object + | json | + json := String streamContents: [ :stream | + (NeoJSONWriter on: stream) asciiOnly: true; nextPut: object ]. + ^ (NeoJSONReader on: json readStream) next \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/properties.json new file mode 100644 index 0000000..c230f7a --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadAsciiOnlyTests.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Neo-JSON-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "NeoJSONWriteReadAsciiOnlyTests", + "pools" : [ + ], + "super" : "NeoJSONWriteReadTests", + "type" : "normal" } diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/README.md new file mode 100644 index 0000000..4af70f7 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/README.md @@ -0,0 +1 @@ +I am NeoJSONWriteReadMockStreamTests. \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/instance/writeRead..st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/instance/writeRead..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/instance/writeRead..st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/instance/writeRead..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/properties.json similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/properties.json diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testDictionaryOfObject2.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testDictionaryOfObject2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testDictionaryOfObject2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testDictionaryOfObject2.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject1.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject1.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject1.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject2.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject2.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject3.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject3.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject3.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/testObject3.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/writeRead..st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/writeRead..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/writeRead..st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/instance/writeRead..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/properties.json similarity index 80% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/properties.json index 5a98984..9e69380 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 6/5/2012 09:50", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONWriteReadPrettyPrintedTests", diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/README.md diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testDictionaryOfObject2.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testDictionaryOfObject2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testDictionaryOfObject2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testDictionaryOfObject2.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testFloats.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testFloats.st new file mode 100644 index 0000000..1143b92 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testFloats.st @@ -0,0 +1,7 @@ +testing +testFloats + | objects | + objects := OrderedCollection new add: Float pi; add: 1.0; add: -1.0; add: 0.0; add: 1.5e6; add: -1.5e6; add: 1.5e-6; add: -1.5e-6; yourself. + (self writeRead: objects) + with: objects + do: [ :first :second | self assert: (first closeTo: second) ] \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testIntegers.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testIntegers.st similarity index 54% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testIntegers.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testIntegers.st index 90c38de..48d1824 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testIntegers.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testIntegers.st @@ -1,7 +1,7 @@ testing testIntegers | objects | - objects := { 1. -1. 0. 123467890. -1234567890 }. + objects := Array with: 1 with: -1 with: 0 with: 123467890 with: -1234567890. self assert: (self writeRead: objects) equals: objects \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testLists.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testLists.st similarity index 57% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testLists.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testLists.st index c038965..8018686 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testLists.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testLists.st @@ -1,7 +1,7 @@ testing testLists | objects | - objects := { #(1 2 3). #(). #( 'foo' 'bar') }. + objects := Array with: #(1 2 3) with: #() with: #( 'foo' 'bar'). self assert: (self writeRead: objects) equals: objects \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testMaps.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testMaps.st new file mode 100644 index 0000000..41b6c5d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testMaps.st @@ -0,0 +1,10 @@ +testing +testMaps + | objects | + objects := Array + with: Dictionary new + with: (Dictionary with: 'x' -> 1) + with: (Dictionary newFromPairs: #( 'foo' true 'bar' false 'zero' 0 'null' nil 'string' 'Hello World!' )). + self + assert: (self writeRead: objects) + equals: objects \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject1.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject1.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject1.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject2.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject2.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject3.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject3.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject3.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testObject3.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testSpecials.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testSpecials.st similarity index 64% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testSpecials.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testSpecials.st index 561a30b..251ed3d 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testSpecials.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testSpecials.st @@ -1,7 +1,7 @@ testing testSpecials | objects | - objects := { true. false. nil }. + objects := Array with: true with: false with: nil. self assert: (self writeRead: objects) equals: objects \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testStrings.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testStrings.st new file mode 100644 index 0000000..6ebeaff --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testStrings.st @@ -0,0 +1,12 @@ +testing +testStrings + | objects | + objects := OrderedCollection new + add: 'foo'; add: 'Foo BAR'; add: ''; add: ' \\'''; + add: 'élève en Français'; + add: (Character codePoint: 12354) asString; "HIRAGANA LETTER A" + yourself; + asArray. + self + assert: (self writeRead: objects) + equals: objects \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeRead..st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeRead..st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeRead..st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeRead..st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeReadAsciiOnly..st b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeReadAsciiOnly..st similarity index 80% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeReadAsciiOnly..st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeReadAsciiOnly..st index f2bacb3..c479047 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeReadAsciiOnly..st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/writeReadAsciiOnly..st @@ -6,4 +6,4 @@ writeReadAsciiOnly: object (NeoJSONWriter on: stream) asciiOnly: true; nextPut: object ]. - ^ (NeoJSONReader on: json readStream) next \ No newline at end of file + ^ (NeoJSONReader on: json readStream) next diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/properties.json similarity index 78% rename from repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/properties.json index 157067f..1c39d34 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 6/4/2012 15:34", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONWriteReadTests", diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/README.md b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/README.md similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/README.md rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/README.md diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAsciiOnlyStrings.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAsciiOnlyStrings.st new file mode 100644 index 0000000..1291ba6 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAsciiOnlyStrings.st @@ -0,0 +1,24 @@ +testing +testAsciiOnlyStrings + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + asciiOnly: true; + nextPut: object ] ]. + self assert: (writer value: 'élève français') equals: '"\u00E9l\u00E8ve fran\u00E7ais"'. + self assert: (writer value: 'foo') equals: '"foo"'. + self assert: (writer value: 'Foo BAR') equals: '"Foo BAR"'. + self assert: (writer value: '') equals: '""'. + self + assert: (writer value: (String withAll: ( OrderedCollection new + add: $"; + add: $\; + add: $/; + add: Character tab; + add: Character cr; + add: Character lf; + add: Character newPage; + add: Character backspace; + yourself ))) + equals: '"\"\\/\t\r\n\f\b"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAssociation.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAssociation.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAssociation.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAssociation.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testBooleans.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testBooleans.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testBooleans.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testBooleans.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testByteArray.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testByteArray.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testByteArray.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testByteArray.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDate.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDate.st similarity index 60% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDate.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDate.st index 3f877e7..a4116d4 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDate.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDate.st @@ -1,10 +1,11 @@ testing testDate - | writer | + | dateClassType writer | + dateClassType := (Smalltalk globals at: #'SmallTime' ifAbsent: [ nil ]) ifNil: [ Date ] ifNotNil: [ SmallDate ]. writer := [ :object | String streamContents: [ :stream | (NeoJSONWriter on: stream) - for: Date customDo: [ :mapping | + for: dateClassType customDo: [ :mapping | mapping encoder: [ :date | date yyyymmdd ] ]; nextPut: object ] ]. self assert: (writer value: (Date newDay: 8 month: 'June' year: 2012)) equals: '"2012-06-08"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDateAndTime.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDateAndTime.st similarity index 63% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDateAndTime.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDateAndTime.st index 9ba04ea..b7fe2b5 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDateAndTime.st +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testDateAndTime.st @@ -1,10 +1,11 @@ testing testDateAndTime - | writer | + | dateAndTimeClassType writer | + dateAndTimeClassType := (Smalltalk globals at: #'SmallTime' ifAbsent: [ nil ]) ifNil: [ DateAndTime ] ifNotNil: [ SmallDateAndTime ]. writer := [ :object | String streamContents: [ :stream | (NeoJSONWriter on: stream) - for: DateAndTime customDo: [ :mapping | + for: SmallDateAndTime customDo: [ :mapping | mapping encoder: [ :dateAndTime | dateAndTime printString ] ]; nextPut: object ] ]. self diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloatPrinter.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloatPrinter.st new file mode 100644 index 0000000..a90e148 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloatPrinter.st @@ -0,0 +1,18 @@ +testing +testFloatPrinter + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + floatPrinter: NeoJSONFloatPrinter new; + nextPut: object ] ]. + self assert: (writer value: 123.0) equals: '123'. + self assert: (writer value: -123.0) equals: '-123'. + self assert: (writer value: 0.0) equals: '0'. + self assert: (writer value: 1.50) equals: '1.5'. + self assert: (writer value: -1.25) equals: '-1.25'. + self assert: (writer value: Float pi) equals: '3.14159'. + self assert: (writer value: 9.10938356e-31) equals: '9.10938e-31'. + self assert: (writer value: 5.9724e24) equals: '5.9724e24'. + self assert: (writer value: 1234567890.1234567890) equals: '1.23457e9'. + self assert: (writer value: (1/3) asFloat) equals: '0.33333'. \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloats.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloats.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloats.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testFloats.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testIntegers.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testIntegers.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testIntegers.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testIntegers.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testLists.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testLists.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testLists.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testLists.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testListsExtra.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testListsExtra.st new file mode 100644 index 0000000..6543c1b --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testListsExtra.st @@ -0,0 +1,10 @@ +testing +testListsExtra + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + #( OrderedCollection LinkedList ByteArray IntegerArray SortedCollection ) do: [ :each | + Smalltalk at: each ifPresent: [ :collectionClass | + self assert: (writer value: (collectionClass withAll: #(1 2 3))) equals: '[1,2,3]'. + self assert: (writer value: collectionClass new) equals: '[]' ] ] diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMapKeysMustBeStrings.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMapKeysMustBeStrings.st new file mode 100644 index 0000000..f28cce1 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMapKeysMustBeStrings.st @@ -0,0 +1,8 @@ +testing +testMapKeysMustBeStrings + self should: [ NeoJSONWriter toString: { 1->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { true->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { nil->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { #()->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { Dictionary new->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { Float pi->#a } asDictionary ] raise: Error. \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMaps.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMaps.st new file mode 100644 index 0000000..5207baf --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMaps.st @@ -0,0 +1,9 @@ +testing +testMaps + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: ((writer value: (Dictionary newFromPairs: #( 'x' 1 'y' 2))) includesSubstring: '"x":1'). + self assert: ((writer value: (Dictionary newFromPairs: #( 'x' 1 'y' 2))) includesSubstring: '"y":2'). + self assert: (writer value: Dictionary new) equals: '{}'. diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMapsExtra.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMapsExtra.st new file mode 100644 index 0000000..1a931b3 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMapsExtra.st @@ -0,0 +1,14 @@ +testing +testMapsExtra + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: (IdentityDictionary newFromPairs: #( 'x' 1))) equals: '{"x":1}'. + self assert: (writer value: IdentityDictionary new) equals: '{}'. + #( SmallDictionary OrderedDictionary OrderedIdentityDictionary ) do: [ :each | + | dictionaryClass | + dictionaryClass := Smalltalk at: each ifAbsent: [ nil ]. + dictionaryClass ifNotNil: [ + self assert: (writer value: (dictionaryClass new at: 'x' put: 1; at: 'y' put: 2; yourself)) equals: '{"x":1,"y":2}'. + self assert: (writer value: dictionaryClass new) equals: '{}'] ] diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNextPutStringAsHex.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNextPutStringAsHex.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNextPutStringAsHex.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNextPutStringAsHex.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNonBMPCharacterEncoding.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNonBMPCharacterEncoding.st new file mode 100644 index 0000000..5a5990d --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNonBMPCharacterEncoding.st @@ -0,0 +1,9 @@ +testing +testNonBMPCharacterEncoding + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + + | string json | + string := 16r1D11E asCharacter asString. "MUSICAL SYMBOL G CLEF" + json := String streamContents: [ :out | + (NeoJSONWriter on: out) asciiOnly: true; nextPut: string ]. + self assert: json equals: '"\uD834\uDD1E"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNull.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNull.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNull.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testNull.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint1.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint1.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint1.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint1.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint2.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint2.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint2.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint2.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint3.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint3.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint3.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPoint3.st diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointUsingAsString.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointUsingAsString.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointUsingAsString.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointUsingAsString.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointWriteNil.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointWriteNil.st new file mode 100644 index 0000000..de64211 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPointWriteNil.st @@ -0,0 +1,11 @@ +testing +testPointWriteNil + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + writeNil: true; + mapAllInstVarsFor: Point; + nextPut: object ] ]. + self assert: (writer value: 1@2) equals: '{"x":1,"y":2}'. + self assert: (writer value: Point new) equals: '{"x":null,"y":null}' \ No newline at end of file diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPreservePropertyOrder.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPreservePropertyOrder.st new file mode 100644 index 0000000..42d5bb9 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testPreservePropertyOrder.st @@ -0,0 +1,26 @@ +testing +testPreservePropertyOrder + | writer testObject | + (testObject := NeoJSONTestObject2 new) + id: 123; + width: 100; + height: 50; + data: 'test'. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(id width height data) ]; + nextPut: object ] ]. + self assert: (writer value: testObject) equals: '{"id":123,"width":100,"height":50,"data":"test"}'. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(width height data id) ]; + nextPut: object ] ]. + self assert: (writer value: testObject) equals: '{"width":100,"height":50,"data":"test","id":123}'. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(data id height width) ]; + nextPut: object ] ]. + self assert: (writer value: testObject) equals: '{"data":"test","id":123,"height":50,"width":100}'. diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testStrings.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testStrings.st new file mode 100644 index 0000000..f267894 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testStrings.st @@ -0,0 +1,21 @@ +testing +testStrings + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: 'foo') equals: '"foo"'. + self assert: (writer value: 'Foo BAR') equals: '"Foo BAR"'. + self assert: (writer value: '') equals: '""'. + self + assert: (writer value: (String withAll: ( OrderedCollection new + add: $"; + add: $\; + add: $/; + add: Character tab; + add: Character cr; + add: Character lf; + add: Character newPage; + add: Character backspace; + yourself ))) + equals: '"\"\\/\t\r\n\f\b"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testSymbol.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testSymbol.st similarity index 100% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testSymbol.st rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testSymbol.st diff --git a/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testTime.st b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testTime.st new file mode 100644 index 0000000..0681855 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testTime.st @@ -0,0 +1,12 @@ +testing +testTime + | timeClassType hourFormat writer | + timeClassType := (Smalltalk globals at: #'SmallTime' ifAbsent: [ nil ]) ifNil: [ Time ] ifNotNil: [ SmallTime ]. + "Hours could be in 12-hour format or 24-hour format" + hourFormat := (Time hour: 14 minute: 0 second: 0) hours = 2 ifTrue: [ '2' ] ifFalse: [ '14' ]. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) for: timeClassType customDo: [ :mapping | + mapping encoder: [ :time | time printString ] ]; + nextPut: object ] ]. + self assert: ((writer value: (Time fromSeconds: 52208)) includesSubstring: hourFormat, ':30:08') \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/properties.json b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/properties.json similarity index 78% rename from repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/properties.json rename to filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/properties.json index f421478..02ad9cd 100644 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/properties.json +++ b/filetree/Neo-JSON-Tests.package/NeoJSONWriterTests.class/properties.json @@ -4,7 +4,7 @@ ], "classvars" : [ ], - "commentStamp" : "SvenVanCaekenberghe 6/2/2012 22:20", + "commentStamp" : "", "instvars" : [ ], "name" : "NeoJSONWriterTests", diff --git a/filetree/Neo-JSON-Tests.package/properties.json b/filetree/Neo-JSON-Tests.package/properties.json new file mode 100644 index 0000000..a097c63 --- /dev/null +++ b/filetree/Neo-JSON-Tests.package/properties.json @@ -0,0 +1,2 @@ +{ + } \ No newline at end of file diff --git a/filetree/properties.st b/filetree/properties.st new file mode 100644 index 0000000..1d56ae3 --- /dev/null +++ b/filetree/properties.st @@ -0,0 +1,4 @@ +{ + #format : 'filetree', + #convention : 'Monticello' +} diff --git a/lepiter/81brlbrknhsro4cxzdl06l22t.bak b/lepiter/81brlbrknhsro4cxzdl06l22t.bak new file mode 100644 index 0000000..5a641c9 --- /dev/null +++ b/lepiter/81brlbrknhsro4cxzdl06l22t.bak @@ -0,0 +1,1222 @@ +{ + "__schema" : "4.1", + "__type" : "page", + "children" : { + "__type" : "snippets", + "items" : [ + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:58.18415+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:49:51.893292+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "AmTLWsPEDQCi43d6A47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "JSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). JSON is a language-independent data format. It was derived from JavaScript, but many modern programming languages include code to generate and parse JSON-format data." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:40.657807+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:40.661675+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "f2zmV8PEDQCipgVSA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "NeoJSON is an elegant and efficient standalone Smalltalk framework to read and write JSON converting to or from Smalltalk objects." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T11:58:50.079586+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T11:59:38.00409+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "7dQtPenEDQCwkkjwCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "# Arrays & Dictionaries" + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T11:59:44.369072+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:19.904615+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "BEJqQOnEDQCxjPmCCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "JSON is defined using a number of primitive types (numbers, strings, booleans and null) and two composite types (lists and maps). Maps consist of unordered key value pairs and are sometimes called objects. Lists contain an ordered collection of JSON values. The natural or generic mapping of these two concepts is to {{gtClass:Array}} and {{gtClass:Dictionary}}. This is what {{gtClass:NeoJSONReader}} does out of the box." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:04:56.100214+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:41.24643+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "cOT+UunEDQC6HlPJCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Let's consider some JSON input." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:49.982516+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:49.982516+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "1JnIWenEDQC8L1vZCLMSBQ==" + }, + "exampleSelector" : "exampleCoordinatesJSON", + "previewHeight" : 200, + "previewShowSelector" : "gtStringFor:", + "exampleBehaviorName" : "NeoJSONReader class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:10.942323+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:49.896313+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "W7XlXenEDQC8h3syCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Here is how to use {{gtClass:NeoJSONReader}} to parse this JSON input." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:58.808255+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:58.808255+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "1VN2YenEDQC+SF0qCLMSBQ==" + }, + "exampleSelector" : "exampleCoordinatesGenericParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONReader class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:09:56.333014+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:10:36.168612+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "3BTkZOnEDQC+rIHICLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "The resulting data structure is an array of dictionaries." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:11:20.602757+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:23:52.709532+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "I+/paenEDQCAHWklCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Generating JSON is done using {{gtClass:NeoJSONWriter}} with this data structure as input. Actually, many collections are considered as lists except those that are explicitly seen as maps because they contain key value pairs. " + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:13:27.745059+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:13:27.745059+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "afp9cenEDQCFexvvCLMSBQ==" + }, + "exampleSelector" : "exampleCoordinatesGenericWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtStringFor:", + "exampleBehaviorName" : "NeoJSONWriter class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:38.934273+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:45.257142+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "5kjjfOnEDQCFy427CLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "# Mapping" + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:47.512544+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:03:04.233496+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "ADJmfenEDQCF9BZpCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "JSON is fully dynamic and does not contain any type or class information. However, users do place meaning on certain JSON constructs. In our coordinates example we can all see that this is a list of x y coordinates, although this is not explicitly defined. So we might be inclined to use {{gtClass:Point}} here. Mapping allows you to make some use of the implicit schema present in JSON, either during parsing or during writing." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:03:13.264218+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:04:58.868156+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "kWFxI+rEDQCvbdhdBdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "For parsing we need to tell the reader about the domain object that we want to use. And although we could have used {{gtMethod:NeoJSONReader>>#nextListAs:}} we defined and used a virtual type, ArrayOfPoints. " + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:01:50.942757+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:01:50.942757+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "jUGJHurEDQCu8xlxBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesCustomParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONReader class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:05:40.597846+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:09:44.12187+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "04M5LOrEDQCz5dG4BdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "For writing, we only need to map Point. Without a mapping, the writer would fail on Point since it does not know how to turn points into JSON." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:06:22.54966+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:06:22.54966+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "Dai5LurEDQC1aiNMBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesCustomWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONWriter class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T15:00:44.919808+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:52.770243+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "SFoSjMPEDQCtn/w5A47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "# NeoJSONObject" + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:52:15.641291+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:26:15.191477+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "oWC3bcPEDQCkF2fPA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Another option is to use {{gtClass:NeoJSONObject}} and {{gtClass:NeoJSONArray}}. These are then used as mapClHere is a small and simple example of JSON, a map with 2 key-value pairs." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:50:22.488316+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:50:22.488316+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "m874ZsPEDQCjnp0hA47Ahw==" + }, + "exampleSelector" : "exampleSimpleJSON", + "previewHeight" : 200, + "previewShowSelector" : "gtStringFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:57:40.534498+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:06:23.066158+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "o9QUgcPEDQCovrAyA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "This corresponds with the following example object:" + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:58:18.972457+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:58:18.972457+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "U2Ffg8PEDQCqYXrCA47Ahw==" + }, + "exampleSelector" : "exampleSimple", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T10:52:41.800972+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:08:17.241982+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "dVXPMtTEDQC1y38DBchSng==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "{{gtClass:NeoJSONObject}} is a subclass of OrderedDictionary which automatically implements accessors using key access. When a key does not exist, nil is returned instead of a {{gtClass:KeyNotFound}} being raised." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:16:16.219788+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:16:16.219788+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "Vq4dh9TEDQC8hjUdBchSng==" + }, + "exampleSelector" : "exampleSimpleUsage", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:53:13.189284+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:21:09.587872+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "2Y7ScMPEDQCl4qMXA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "One convenient way to parse JSON is to use {{gtMethod: NeoJSONObject class>>#fromString:}}." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:53:54.818539+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:53:54.818539+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "b7Wgc8PEDQCnNYsqA47Ahw==" + }, + "exampleSelector" : "exampleSimpleParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:58:59.204816+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T10:52:03.553046+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "LFqyf8PEDQCol8EmA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "The inverse operation, from an object to JSON is also convenient, given it is a {{gtClass:NeoJSONObject}} whose {{gtMethod: NeoJSONObject>>#printOn:}} outputs JSON." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:59:55.641591+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:59:55.641591+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "c28iicPEDQCtTBTqA47Ahw==" + }, + "exampleSelector" : "exampleSimpleWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:15:58.018722+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:16:34.590223+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "upYGUerEDQC3uiMoBdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "The next two examples show how to work with the coordinates example." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:16:55.662258+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:16:55.662258+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "Yy52VOrEDQC5snhFBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:17:12.624073+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:17:12.624073+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "wv94VerEDQC5uU/RBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + } + ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:09.552647+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:58.17813+02:00" + } + }, + "pageType" : { + "__type" : "namedPage", + "title" : "Parsing and Writing JSON" + }, + "uid" : { + "__type" : "uuid", + "uuid" : "c553e557-c3c4-0d00-a2a5-cc1e038ec087" + } +} \ No newline at end of file diff --git a/lepiter/81brlbrknhsro4cxzdl06l22t.lepiter b/lepiter/81brlbrknhsro4cxzdl06l22t.lepiter new file mode 100644 index 0000000..0ed6103 --- /dev/null +++ b/lepiter/81brlbrknhsro4cxzdl06l22t.lepiter @@ -0,0 +1,1259 @@ +{ + "__schema" : "4.1", + "__type" : "page", + "children" : { + "__type" : "snippets", + "items" : [ + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:58.18415+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:49:51.893292+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "AmTLWsPEDQCi43d6A47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "JSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). JSON is a language-independent data format. It was derived from JavaScript, but many modern programming languages include code to generate and parse JSON-format data." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:40.657807+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:40.661675+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "f2zmV8PEDQCipgVSA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "NeoJSON is an elegant and efficient standalone Smalltalk framework to read and write JSON converting to or from Smalltalk objects." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T11:58:50.079586+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T11:59:38.00409+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "7dQtPenEDQCwkkjwCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "# Arrays & Dictionaries" + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T11:59:44.369072+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:19.904615+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "BEJqQOnEDQCxjPmCCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "JSON is defined using a number of primitive types (numbers, strings, booleans and null) and two composite types (lists and maps). Maps consist of unordered key value pairs and are sometimes called objects. Lists contain an ordered collection of JSON values. The natural or generic mapping of these two concepts is to {{gtClass:Array}} and {{gtClass:Dictionary}}. This is what {{gtClass:NeoJSONReader}} does out of the box." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:04:56.100214+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:41.24643+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "cOT+UunEDQC6HlPJCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Let's consider some JSON input." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:49.982516+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:06:49.982516+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "1JnIWenEDQC8L1vZCLMSBQ==" + }, + "exampleSelector" : "exampleCoordinatesJSON", + "previewHeight" : 200, + "previewShowSelector" : "gtStringFor:", + "exampleBehaviorName" : "NeoJSONReader class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:10.942323+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:49.896313+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "W7XlXenEDQC8h3syCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Here is how to use {{gtClass:NeoJSONReader}} to parse this JSON input." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:58.808255+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:08:58.808255+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "1VN2YenEDQC+SF0qCLMSBQ==" + }, + "exampleSelector" : "exampleCoordinatesGenericParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONReader class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:09:56.333014+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:10:36.168612+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "3BTkZOnEDQC+rIHICLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "The resulting data structure is an array of dictionaries." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:11:20.602757+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:23:52.709532+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "I+/paenEDQCAHWklCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Generating JSON is done using {{gtClass:NeoJSONWriter}} with this data structure as input. Actually, many collections are considered as lists except those that are explicitly seen as maps because they contain key value pairs. " + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:13:27.745059+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:13:27.745059+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "afp9cenEDQCFexvvCLMSBQ==" + }, + "exampleSelector" : "exampleCoordinatesGenericWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtStringFor:", + "exampleBehaviorName" : "NeoJSONWriter class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:38.934273+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:45.257142+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "5kjjfOnEDQCFy427CLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "# Mapping" + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:47.512544+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:03:04.233496+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "ADJmfenEDQCF9BZpCLMSBQ==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "JSON is fully dynamic and does not contain any type or class information. However, users do place meaning on certain JSON constructs. In our coordinates example we can all see that this is a list of x y coordinates, although this is not explicitly defined. So we might be inclined to use {{gtClass:Point}} here. Mapping allows you to make some use of the implicit schema present in JSON, either during parsing or during writing." + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:03:13.264218+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:04:58.868156+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "kWFxI+rEDQCvbdhdBdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "For parsing we need to tell the reader about the domain object that we want to use. And although we could have used {{gtMethod:NeoJSONReader>>#nextListAs:}} we defined and used a virtual type, ArrayOfPoints. " + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:01:50.942757+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:01:50.942757+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "jUGJHurEDQCu8xlxBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesCustomParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONReader class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:05:40.597846+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:09:44.12187+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "04M5LOrEDQCz5dG4BdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "For writing, we only need to map Point. Without a mapping, the writer would fail on Point since it does not know how to turn points into JSON." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:06:22.54966+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:06:22.54966+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "Dai5LurEDQC1aiNMBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesCustomWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONWriter class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T15:00:44.919808+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T12:16:52.770243+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "SFoSjMPEDQCtn/w5A47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "# NeoJSONObject" + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:26:33.484917+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:26:33.484917+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "aA/ndurEDQC7ZHW+BdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Another option is to use {{gtClass:NeoJSONObject}} and {{gtClass:NeoJSONArray}}. These are then used as mapClass and listClass instead of Dictionary and Array. " + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:52:15.641291+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:26:33.48926+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "oWC3bcPEDQCkF2fPA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "Here is a small and simple example of JSON, a map with 2 key-value pairs." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:50:22.488316+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:50:22.488316+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "m874ZsPEDQCjnp0hA47Ahw==" + }, + "exampleSelector" : "exampleSimpleJSON", + "previewHeight" : 200, + "previewShowSelector" : "gtStringFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:57:40.534498+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:06:23.066158+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "o9QUgcPEDQCovrAyA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "This corresponds with the following example object:" + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:58:18.972457+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:58:18.972457+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "U2Ffg8PEDQCqYXrCA47Ahw==" + }, + "exampleSelector" : "exampleSimple", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T10:52:41.800972+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:08:17.241982+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "dVXPMtTEDQC1y38DBchSng==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "{{gtClass:NeoJSONObject}} is a subclass of OrderedDictionary which automatically implements accessors using key access. When a key does not exist, nil is returned instead of a {{gtClass:KeyNotFound}} being raised." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:16:16.219788+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:16:16.219788+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "Vq4dh9TEDQC8hjUdBchSng==" + }, + "exampleSelector" : "exampleSimpleUsage", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:53:13.189284+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T11:21:09.587872+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "2Y7ScMPEDQCl4qMXA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "One convenient way to parse JSON is to use {{gtMethod: NeoJSONObject class>>#fromString:}}." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:53:54.818539+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:53:54.818539+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "b7Wgc8PEDQCnNYsqA47Ahw==" + }, + "exampleSelector" : "exampleSimpleParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:58:59.204816+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-24T10:52:03.553046+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "LFqyf8PEDQCol8EmA47Ahw==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "The inverse operation, from an object to JSON is also convenient, given it is a {{gtClass:NeoJSONObject}} whose {{gtMethod: NeoJSONObject>>#printOn:}} outputs JSON." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:59:55.641591+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:59:55.641591+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "c28iicPEDQCtTBTqA47Ahw==" + }, + "exampleSelector" : "exampleSimpleWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "textSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:15:58.018722+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:16:34.590223+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "upYGUerEDQC3uiMoBdJ9wA==" + }, + "paragraphStyle" : { + "__type" : "textStyle" + }, + "string" : "The next two examples show how to work with the coordinates example." + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:16:55.662258+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:16:55.662258+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "Yy52VOrEDQC5snhFBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesWriting", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + }, + { + "__type" : "exampleSnippet", + "children" : { + "__type" : "snippets", + "items" : [ ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:17:12.624073+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-25T13:17:12.624073+02:00" + } + }, + "uid" : { + "__type" : "uid", + "uidString" : "wv94VerEDQC5uU/RBdJ9wA==" + }, + "exampleSelector" : "exampleCoordinatesParsing", + "previewHeight" : 200, + "previewShowSelector" : "gtViewsFor:", + "exampleBehaviorName" : "NeoJSONObject class", + "codeExpanded" : true, + "previewExpanded" : false, + "noCode" : false + } + ] + }, + "createEmail" : { + "__type" : "email", + "emailString" : "" + }, + "createTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:09.552647+02:00" + } + }, + "editEmail" : { + "__type" : "email", + "emailString" : "" + }, + "editTime" : { + "__type" : "time", + "time" : { + "__type" : "dateAndTime", + "dateAndTimeString" : "2023-10-23T14:46:58.17813+02:00" + } + }, + "pageType" : { + "__type" : "namedPage", + "title" : "Parsing and Writing JSON" + }, + "uid" : { + "__type" : "uuid", + "uuid" : "c553e557-c3c4-0d00-a2a5-cc1e038ec087" + } +} \ No newline at end of file diff --git a/lepiter/lepiter.properties b/lepiter/lepiter.properties new file mode 100644 index 0000000..d57cfb4 --- /dev/null +++ b/lepiter/lepiter.properties @@ -0,0 +1,4 @@ +{ + "uuid" : "f8e32c57-c3c4-0d00-a2a4-02c0038ec087", + "schema" : "4.1" +} \ No newline at end of file diff --git a/repository/.filetree b/repository/.filetree deleted file mode 100644 index febe4a5..0000000 --- a/repository/.filetree +++ /dev/null @@ -1 +0,0 @@ -{ "packageExtension" : ".package" } diff --git a/repository/.properties b/repository/.properties new file mode 100644 index 0000000..13c9868 --- /dev/null +++ b/repository/.properties @@ -0,0 +1,4 @@ +{ + #format : #tonel, + #convention : 'Monticello' +} diff --git a/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st b/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st deleted file mode 100644 index c1df617..0000000 --- a/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/instance/baseline..st +++ /dev/null @@ -1,22 +0,0 @@ -baselines -baseline: spec - - spec - for: #'common' - do: [ - spec - baseline: 'GLASS1' - with: [ - spec - loads: #('GsSqueakCommon'); - repository: 'github://glassdb/glass:master/repository' ]; - yourself. - spec - package: 'Neo-JSON-Core' with: [ spec requires: 'GLASS1' ]; - package: 'Neo-JSON-Tests' with: [ spec requires: 'Neo-JSON-Core' ]; - yourself. - spec - group: 'default' with: #('Neo-JSON-Core' 'Neo-JSON-Tests'); - group: 'Core' with: #('Neo-JSON-Core'); - group: 'Tests' with: #('Neo-JSON-Tests'); - yourself ] \ No newline at end of file diff --git a/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/methodProperties.json b/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/methodProperties.json deleted file mode 100644 index d9dabe6..0000000 --- a/repository/BaselineOfNeoJSON.package/BaselineOfNeoJSON.class/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "baseline:" : "dkh 11/21/2014 21:39" } } diff --git a/repository/BaselineOfNeoJSON.package/monticello.meta/categories.st b/repository/BaselineOfNeoJSON.package/monticello.meta/categories.st deleted file mode 100644 index 5ae7bf7..0000000 --- a/repository/BaselineOfNeoJSON.package/monticello.meta/categories.st +++ /dev/null @@ -1 +0,0 @@ -SystemOrganization addCategory: #'BaselineOfNeoJSON'! diff --git a/repository/BaselineOfNeoJSON.package/monticello.meta/package b/repository/BaselineOfNeoJSON.package/monticello.meta/package deleted file mode 100644 index 11d829c..0000000 --- a/repository/BaselineOfNeoJSON.package/monticello.meta/package +++ /dev/null @@ -1 +0,0 @@ -(name 'BaselineOfNeoJSON') \ No newline at end of file diff --git a/repository/BaselineOfNeoJSON.package/monticello.meta/version b/repository/BaselineOfNeoJSON.package/monticello.meta/version deleted file mode 100644 index 433d9d7..0000000 --- a/repository/BaselineOfNeoJSON.package/monticello.meta/version +++ /dev/null @@ -1 +0,0 @@ -(name 'BaselineOfNeoJSON-dkh.2' message 'move some methods to GsSqueakCommon ... tweak baseline' id '8c59d8da-bd33-4675-948e-6db92c78c7d8' date '11/21/2014' time '21:39:49' author 'dkh' ancestors ((name 'BaselineOfNeoJSON-PaulDeBruicker.1' message 'Copy of Dale''s BaselineOfNeoJSON from the glassdb repo' id '8b37955b-ce25-41f7-8190-7f69d6b3828c' date '11/02/2014' time '19:58:37' author 'PaulDeBruicker' ancestors () stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/repository/BaselineOfNeoJSON.package/properties.json b/repository/BaselineOfNeoJSON.package/properties.json deleted file mode 100644 index f037444..0000000 --- a/repository/BaselineOfNeoJSON.package/properties.json +++ /dev/null @@ -1,2 +0,0 @@ -{ - } diff --git a/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st b/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st new file mode 100644 index 0000000..eef15a6 --- /dev/null +++ b/repository/BaselineOfNeoJSON/BaselineOfNeoJSON.class.st @@ -0,0 +1,31 @@ +" +I am BaselineOfNeoJSON, I load the code for the NeoJSON project. +I am a BaselineOf. +" +Class { + #name : #BaselineOfNeoJSON, + #superclass : #BaselineOf, + #category : #BaselineOfNeoJSON +} + +{ #category : #baselines } +BaselineOfNeoJSON >> baseline: spec [ + + spec + for: #common + do: [ spec + package: 'Neo-JSON-Core'; + package: 'Neo-JSON-Tests' with: [ spec requires: #('Neo-JSON-Core') ]; + group: 'default' with: #('Core' 'Tests'); + group: 'Core' with: #('Neo-JSON-Core'); + group: 'Tests' with: #('Neo-JSON-Tests') ]. + spec + for: #pharo + do: [ spec + package: 'Neo-JSON-Pharo-Core' with: [ spec requires: #('Neo-JSON-Core') ]; + package: 'Neo-JSON-Pharo-Tests' with: [ spec requires: #('Neo-JSON-Tests') ]; + package: 'Neo-JSON-Pharo-Examples' with: [ spec requires: #('Neo-JSON-Core') ]; + group: 'Core' with: #('Neo-JSON-Core' 'Neo-JSON-Pharo-Core'); + group: 'Tests' with: #('Neo-JSON-Tests' 'Neo-JSON-Pharo-Tests'); + group: 'Examples' with: #('Neo-JSON-Pharo-Examples') ]. +] diff --git a/repository/BaselineOfNeoJSON/package.st b/repository/BaselineOfNeoJSON/package.st new file mode 100644 index 0000000..90e5053 --- /dev/null +++ b/repository/BaselineOfNeoJSON/package.st @@ -0,0 +1 @@ +Package { #name : #BaselineOfNeoJSON } diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/README.md b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/README.md deleted file mode 100644 index a4abe8c..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/README.md +++ /dev/null @@ -1,3 +0,0 @@ -I am ConfigurationOfNeoJSON, a Metacello configuration for NeoJSON. - -NeoJSON is a flexible and efficient reader and writer for JSON. \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/DevelopmentSupport.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/DevelopmentSupport.st deleted file mode 100644 index f188387..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/DevelopmentSupport.st +++ /dev/null @@ -1,5 +0,0 @@ -development support -DevelopmentSupport - -"See the methods in the 'development support' category on the class-side of MetacelloBaseConfiguration. Decide what development support methods you would like to use and copy them the the class-side of your configuration." - diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/baseConfigurationClassIfAbsent..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/baseConfigurationClassIfAbsent..st deleted file mode 100644 index e906812..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/baseConfigurationClassIfAbsent..st +++ /dev/null @@ -1,8 +0,0 @@ -private -baseConfigurationClassIfAbsent: aBlock - - ^Smalltalk - at: #MetacelloBaseConfiguration - ifAbsent: [ - self ensureMetacelloBaseConfiguration. - Smalltalk at: #MetacelloBaseConfiguration ifAbsent: aBlock ]. diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/ensureMetacello.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/ensureMetacello.st deleted file mode 100644 index 869b381..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/ensureMetacello.st +++ /dev/null @@ -1,4 +0,0 @@ -private -ensureMetacello - - (self baseConfigurationClassIfAbsent: []) ensureMetacello \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/ensureMetacelloBaseConfiguration.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/ensureMetacelloBaseConfiguration.st deleted file mode 100644 index 7605398..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/ensureMetacelloBaseConfiguration.st +++ /dev/null @@ -1,14 +0,0 @@ -private -ensureMetacelloBaseConfiguration - - Smalltalk - at: #MetacelloBaseConfiguration - ifAbsent: [ - | repository version | - repository := MCHttpRepository location: 'http://seaside.gemstone.com/ss/metacello' user: '' password: ''. - repository - versionReaderForFileNamed: 'Metacello-Base-DaleHenrichs.2.mcz' - do: [ :reader | - version := reader version. - version load. - version workingCopy repositoryGroup addRepository: repository ] ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/isMetacelloConfig.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/isMetacelloConfig.st deleted file mode 100644 index 98d81c7..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/isMetacelloConfig.st +++ /dev/null @@ -1,5 +0,0 @@ -metacello tool support -isMetacelloConfig - "Answer true and the Metacello tools will operate on you" - - ^true \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/load.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/load.st deleted file mode 100644 index cfb70d4..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/load.st +++ /dev/null @@ -1,8 +0,0 @@ -loading -load - "Load the #stable version defined for this platform. The #stable version is the version that is recommended to be used on this platform." - - "self load" - - - ^(self project version: #stable) load \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/loadBleedingEdge.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/loadBleedingEdge.st deleted file mode 100644 index e780e1d..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/loadBleedingEdge.st +++ /dev/null @@ -1,8 +0,0 @@ -loading -loadBleedingEdge - "Load the latest versions of the mcz files defined for this project. It is not likely that the #bleedingEdge has been tested." - - "self loadBleedingEdge" - - - ^(self project version: #bleedingEdge) load \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/loadDevelopment.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/loadDevelopment.st deleted file mode 100644 index 2ccd72a..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/loadDevelopment.st +++ /dev/null @@ -1,8 +0,0 @@ -loading -loadDevelopment - "Load the #development version defined for this platform. The #development version will change over time and is not expected to be stable." - - "self loadDevelopment" - - - ^(self project version: #development) load \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/project.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/project.st deleted file mode 100644 index 925935b..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/project.st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -project - - ^self new project \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/validate.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/validate.st deleted file mode 100644 index 589fc0b..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/class/validate.st +++ /dev/null @@ -1,12 +0,0 @@ -development support -validate - "Check the configuration for Errors, Critical Warnings, and Warnings (see class comment for MetacelloMCVersionValidator for more information). - Errors identify specification issues that will result in unexpected behaviour when you load the configuration. - Critical Warnings identify specification issues that may result in unexpected behavior when you load the configuration. - Warnings identify specification issues that are technically correct, but are worth take a look at." - - "self validate" - - - self ensureMetacello. - ^ ((Smalltalk at: #MetacelloToolBox) validateConfiguration: self debug: #() recurse: false) explore \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/baseline1..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/baseline1..st deleted file mode 100644 index 85f7a25..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/baseline1..st +++ /dev/null @@ -1,13 +0,0 @@ -baselines -baseline1: spec - - - spec for: #common do: [ - spec - blessing: #baseline; - repository: 'http://mc.stfx.eu/Neo'; - package: 'Neo-JSON-Core'; - package: 'Neo-JSON-Tests' with: [ spec requires: 'Neo-JSON-Core' ]; - group: 'default' with: #('Neo-JSON-Core' 'Neo-JSON-Tests'); - group: 'Core' with: #('Neo-JSON-Core'); - group: 'Tests' with: #('Neo-JSON-Tests') ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/baseline2..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/baseline2..st deleted file mode 100644 index b553d76..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/baseline2..st +++ /dev/null @@ -1,20 +0,0 @@ -baselines -baseline2: spec - - spec - for: #common - do: [ - spec - blessing: #baseline; - repository: 'http://mc.stfx.eu/Neo'; - package: 'Neo-JSON-Core'; - package: 'Neo-JSON-Tests' with: [ spec requires: 'Neo-JSON-Core' ]; - group: 'default' with: #('Neo-JSON-Core' 'Neo-JSON-Tests'); - group: 'Core' with: #('Neo-JSON-Core'); - group: 'Tests' with: #('Neo-JSON-Tests') ]. - spec - for: #gemstone - do: [ - spec - baseline: 'NeoJSON' with: [ spec repository: 'github://GsDevKit/NeoJSON:master/repository' ]; - import: 'NeoJSON' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/project.st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/project.st deleted file mode 100644 index 43dcd87..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/project.st +++ /dev/null @@ -1,11 +0,0 @@ -accessing -project - - ^ project ifNil: [ | constructor | - "Bootstrap Metacello if it is not already loaded" - (self class baseConfigurationClassIfAbsent: []) ensureMetacello. - "Construct Metacello project" - constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self. - project := constructor project. - project loadType: #linear. "change to #atomic if desired" - project ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/stable..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/stable..st deleted file mode 100644 index 7d60b55..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/stable..st +++ /dev/null @@ -1,6 +0,0 @@ -symbolic versions -stable: spec - - - spec for: #common version: '9'. - spec for: #gemstone version: '10'. \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version1..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version1..st deleted file mode 100644 index efbc61f..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version1..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version1: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.17'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.15' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version10..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version10..st deleted file mode 100644 index 44227e5..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version10..st +++ /dev/null @@ -1,15 +0,0 @@ -versions -version10: spec - - spec - for: #common - do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.27'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.24' ]. - spec - for: #'gs3.x' - do: [ - spec import: 'NeoJSON'. - spec baseline: 'NeoJSON' with: [ spec repository: 'github://GsDevKit/NeoJSON:master/repository' ] ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version2..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version2..st deleted file mode 100644 index 4b57665..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version2..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version2: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.19'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.16' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version3..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version3..st deleted file mode 100644 index 7731134..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version3..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version3: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.20'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.16' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version4..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version4..st deleted file mode 100644 index f356d39..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version4..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version4: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.23'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.18' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version5..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version5..st deleted file mode 100644 index ce3a48c..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version5..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version5: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.24'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.19' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version6..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version6..st deleted file mode 100644 index 47d529b..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version6..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version6: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.24'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.20' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version7..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version7..st deleted file mode 100644 index dc49603..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version7..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version7: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.24'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.21' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version8..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version8..st deleted file mode 100644 index e827cd3..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version8..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version8: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.24'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.22' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version9..st b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version9..st deleted file mode 100644 index 94a6e04..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/instance/version9..st +++ /dev/null @@ -1,9 +0,0 @@ -versions -version9: spec - - - spec for: #common do: [ - spec - blessing: #release; - package: 'Neo-JSON-Core' with: 'Neo-JSON-Core-SvenVanCaekenberghe.27'; - package: 'Neo-JSON-Tests' with: 'Neo-JSON-Tests-SvenVanCaekenberghe.24' ] \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/methodProperties.json b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/methodProperties.json deleted file mode 100644 index af307b3..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/methodProperties.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "class" : { - "DevelopmentSupport" : "SvenVanCaekenberghe 6/22/2012 16:48", - "baseConfigurationClassIfAbsent:" : "SvenVanCaekenberghe 6/22/2012 16:48", - "ensureMetacello" : "SvenVanCaekenberghe 6/22/2012 16:48", - "ensureMetacelloBaseConfiguration" : "SvenVanCaekenberghe 6/22/2012 16:48", - "isMetacelloConfig" : "SvenVanCaekenberghe 6/22/2012 16:48", - "load" : "SvenVanCaekenberghe 6/22/2012 16:48", - "loadBleedingEdge" : "SvenVanCaekenberghe 6/22/2012 16:48", - "loadDevelopment" : "SvenVanCaekenberghe 6/22/2012 16:48", - "project" : "SvenVanCaekenberghe 6/22/2012 16:48", - "validate" : "SvenVanCaekenberghe 6/22/2012 16:48" }, - "instance" : { - "baseline1:" : "SvenVanCaekenberghe 6/22/2012 16:53", - "baseline2:" : "PaulDeBruicker 11/2/2014 20:39", - "project" : "SvenVanCaekenberghe 6/22/2012 16:48", - "stable:" : "PaulDeBruicker 11/2/2014 20:39", - "version10:" : "PaulDeBruicker 11/2/2014 20:40", - "version1:" : "SvenVanCaekenberghe 9/27/2012 20:29", - "version2:" : "SvenVanCaekenberghe 12/18/2012 10:27", - "version3:" : "SvenVanCaekenberghe 5/29/2013 15:54", - "version4:" : "SvenVanCaekenberghe 8/30/2013 11:12", - "version5:" : "SvenVanCaekenberghe 9/3/2013 12:22", - "version6:" : "SvenVanCaekenberghe 12/27/2013 19:02", - "version7:" : "SvenVanCaekenberghe 12/27/2013 21:44", - "version8:" : "SvenVanCaekenberghe 1/21/2014 20:08", - "version9:" : "SvenVanCaekenberghe 4/24/2014 13:29" } } diff --git a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/properties.json b/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/properties.json deleted file mode 100644 index 9ba2659..0000000 --- a/repository/ConfigurationOfNeoJSON.package/ConfigurationOfNeoJSON.class/properties.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "category" : "ConfigurationOfNeoJSON", - "classinstvars" : [ - ], - "classvars" : [ - "LastVersionLoad" ], - "commentStamp" : "", - "instvars" : [ - "project" ], - "name" : "ConfigurationOfNeoJSON", - "pools" : [ - ], - "super" : "Object", - "type" : "normal" } diff --git a/repository/ConfigurationOfNeoJSON.package/monticello.meta/categories.st b/repository/ConfigurationOfNeoJSON.package/monticello.meta/categories.st deleted file mode 100644 index 717f992..0000000 --- a/repository/ConfigurationOfNeoJSON.package/monticello.meta/categories.st +++ /dev/null @@ -1 +0,0 @@ -SystemOrganization addCategory: #ConfigurationOfNeoJSON! diff --git a/repository/ConfigurationOfNeoJSON.package/monticello.meta/package b/repository/ConfigurationOfNeoJSON.package/monticello.meta/package deleted file mode 100644 index f0d0ef7..0000000 --- a/repository/ConfigurationOfNeoJSON.package/monticello.meta/package +++ /dev/null @@ -1 +0,0 @@ -(name 'ConfigurationOfNeoJSON') \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/monticello.meta/version b/repository/ConfigurationOfNeoJSON.package/monticello.meta/version deleted file mode 100644 index 0b2bf29..0000000 --- a/repository/ConfigurationOfNeoJSON.package/monticello.meta/version +++ /dev/null @@ -1 +0,0 @@ -(name 'ConfigurationOfNeoJSON-PaulDeBruicker.11' message 'Added GemStone to the configuration' id '568062a9-b890-418e-91f1-428f5ed94522' date '2 November 2014' time '8:40:58.359238 pm' author 'PaulDeBruicker' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.10' message 'updated to #stable v9' id '14b025d0-da85-481f-924f-39f5fbdbc929' date '24 April 2014' time '1:30:05.463071 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.9' message 'v8' id '7ed1d4a7-e738-401a-9cac-69b85aa16b2e' date '21 January 2014' time '8:08:56.986201 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.8' message 'updated to stable v7' id '679ab4c1-1a64-426f-89ca-21722fc74519' date '27 December 2013' time '9:45:29.870451 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.7' message 'updated to stable v6' id '820b367a-f793-4fac-b5a2-1dd1ac73e48e' date '27 December 2013' time '7:03:35.869612 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.6' message 'New feature: NeoJSONWriter>>#asciiOnly: to escape all non ASCII characters in strings' id '27393a62-ca8a-4ad4-808c-ab2f6af1eff3' date '3 September 2013' time '12:23:21.522443 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.5' message 'updated to v4' id '7a79620f-07ab-4204-b37d-160779d1b946' date '30 August 2013' time '11:12:49.896139 am' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.4' message 'stable v3' id '8351f635-abd1-44eb-803b-05ae75b962d8' date '29 May 2013' time '3:54:34.113576 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.3' message 'stable version 2' id '4b6f70ed-72be-4f87-82a6-2f9745d99eba' date '18 December 2012' time '10:28:02.924 am' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.2' message 'added spec blessing: #release to all versiosn' id 'da8a252c-180e-4245-84d6-c0f0b3c43d8d' date '27 September 2012' time '8:30:34.121 pm' author 'SvenVanCaekenberghe' ancestors ((name 'ConfigurationOfNeoJSON-SvenVanCaekenberghe.1' message '1st version' id '43b49eb6-24b6-4665-a7b7-88fafe008cf9' date '22 June 2012' time '4:56:37.24 pm' author 'SvenVanCaekenberghe' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/repository/ConfigurationOfNeoJSON.package/properties.json b/repository/ConfigurationOfNeoJSON.package/properties.json deleted file mode 100644 index f037444..0000000 --- a/repository/ConfigurationOfNeoJSON.package/properties.json +++ /dev/null @@ -1,2 +0,0 @@ -{ - } diff --git a/repository/Neo-JSON-Core.package/Boolean.extension/methodProperties.json b/repository/Neo-JSON-Core.package/Boolean.extension/methodProperties.json deleted file mode 100644 index 7893d0b..0000000 --- a/repository/Neo-JSON-Core.package/Boolean.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "SvenVanCaekenberghe 6/2/2012 22:14" } } diff --git a/repository/Neo-JSON-Core.package/CharacterCollection.extension/methodProperties.json b/repository/Neo-JSON-Core.package/CharacterCollection.extension/methodProperties.json deleted file mode 100644 index 5868ec8..0000000 --- a/repository/Neo-JSON-Core.package/CharacterCollection.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "dkh 11/24/2014 21:39" } } diff --git a/repository/Neo-JSON-Core.package/CharacterCollection.extension/properties.json b/repository/Neo-JSON-Core.package/CharacterCollection.extension/properties.json deleted file mode 100644 index c85a513..0000000 --- a/repository/Neo-JSON-Core.package/CharacterCollection.extension/properties.json +++ /dev/null @@ -1,2 +0,0 @@ -{ - "name" : "CharacterCollection" } diff --git a/repository/Neo-JSON-Core.package/Collection.extension/methodProperties.json b/repository/Neo-JSON-Core.package/Collection.extension/methodProperties.json deleted file mode 100644 index 46d377c..0000000 --- a/repository/Neo-JSON-Core.package/Collection.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "SvenVanCaekenberghe 6/3/2012 19:29" } } diff --git a/repository/Neo-JSON-Core.package/Dictionary.extension/methodProperties.json b/repository/Neo-JSON-Core.package/Dictionary.extension/methodProperties.json deleted file mode 100644 index 28999eb..0000000 --- a/repository/Neo-JSON-Core.package/Dictionary.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "SvenVanCaekenberghe 6/3/2012 19:30" } } diff --git a/repository/Neo-JSON-Core.package/Integer.extension/methodProperties.json b/repository/Neo-JSON-Core.package/Integer.extension/methodProperties.json deleted file mode 100644 index b55faec..0000000 --- a/repository/Neo-JSON-Core.package/Integer.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "SvenVanCaekenberghe 6/2/2012 22:17" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType..st b/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType..st deleted file mode 100644 index 6187090..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/instance/listOfType..st +++ /dev/null @@ -1,11 +0,0 @@ -mapping -listOfType: collectionClass - "Set the reader to a block that will create an instance of collectionClass - using #streamContents: while reading a list of elements" - - self reader: [ :jsonReader | - collectionClass streamContents: [ :stream | - jsonReader parseListDo: [ | element | - element := jsonReader next. - stream nextPut: element ] ] ] - "we do not set a writer, #neoJsonOn: should be sufficient" \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/methodProperties.json deleted file mode 100644 index 2710d00..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONCustomMapping.class/methodProperties.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "decoder:" : "SvenVanCaekenberghe 6/13/2012 11:14", - "encoder:" : "SvenVanCaekenberghe 6/13/2012 11:14", - "identifier" : "SvenVanCaekenberghe 3/23/2014 19:24", - "listOfElementSchema:" : "SvenVanCaekenberghe 6/13/2012 11:38", - "listOfType:" : "SvenVanCaekenberghe 6/13/2012 11:25", - "listOfType:andElementSchema:" : "SvenVanCaekenberghe 6/13/2012 11:39", - "mapWithValueSchema:" : "SvenVanCaekenberghe 8/30/2013 11:04", - "readFrom:" : "SvenVanCaekenberghe 3/24/2014 10:34", - "reader:" : "SvenVanCaekenberghe 3/24/2014 10:36", - "schemaName:" : "SvenVanCaekenberghe 6/8/2012 21:09", - "writeObject:on:" : "SvenVanCaekenberghe 3/23/2014 22:10", - "writer:" : "SvenVanCaekenberghe 3/23/2014 22:12" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONMapper.class/methodProperties.json deleted file mode 100644 index 58809e0..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMapper.class/methodProperties.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "customMappingFor:" : "SvenVanCaekenberghe 3/22/2014 10:57", - "for:customDo:" : "SvenVanCaekenberghe 3/22/2014 10:56", - "for:do:" : "SvenVanCaekenberghe 3/22/2014 10:57", - "mapAllInstVarsFor:" : "SvenVanCaekenberghe 3/22/2014 10:54", - "mapInstVarsFor:" : "SvenVanCaekenberghe 3/22/2014 10:54", - "mappingFor:" : "SvenVanCaekenberghe 6/12/2012 15:48", - "mappingFor:ifAbsent:" : "SvenVanCaekenberghe 6/9/2012 18:24", - "mappings" : "SvenVanCaekenberghe 6/7/2012 14:55", - "objectMappingFor:" : "SvenVanCaekenberghe 3/22/2014 10:54", - "resolveMappingFor:" : "SvenVanCaekenberghe 6/9/2012 18:29" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONMapping.class/methodProperties.json deleted file mode 100644 index eda1e34..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMapping.class/methodProperties.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "identifier" : "SvenVanCaekenberghe 3/23/2014 19:22", - "printOn:" : "SvenVanCaekenberghe 3/23/2014 19:24", - "readFrom:" : "SvenVanCaekenberghe 3/23/2014 19:23", - "writeObject:on:" : "SvenVanCaekenberghe 3/23/2014 19:23" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/README.md b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/README.md deleted file mode 100644 index 9e28acc..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/README.md +++ /dev/null @@ -1,4 +0,0 @@ -I am NeoJSONMappingNotFound. -I am a NotFound exception. - -I am signalled when no mapping is found for a schema. \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection..st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection..st deleted file mode 100644 index 089a4f6..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection..st +++ /dev/null @@ -1,5 +0,0 @@ -updating -collection: newValue - - "Modify the value of the instance variable 'signaler'." - signaler := newValue \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection.st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection.st deleted file mode 100644 index c603f9b..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/collection.st +++ /dev/null @@ -1,5 +0,0 @@ -accessing -collection - - "Return the value of the instance variable 'signaler'." - ^self signaler \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/messageText.st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/messageText.st deleted file mode 100644 index b081b96..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/messageText.st +++ /dev/null @@ -1,5 +0,0 @@ -as yet unclassified -messageText - "Overwritten to initialiaze the message text to a standard text if it has not yet been set" - - ^ messageText ifNil: [ messageText := self standardMessageText ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object..st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object..st deleted file mode 100644 index a86c6f6..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object..st +++ /dev/null @@ -1,5 +0,0 @@ -updating -object: newValue - - "Modify the value of the instance variable 'object'." - object := newValue \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object.st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object.st deleted file mode 100644 index 5cdddb5..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/object.st +++ /dev/null @@ -1,5 +0,0 @@ -accessing -object - - "Return the value of the instance variable 'object'." - ^object \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/signaler..st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/signaler..st deleted file mode 100644 index 8d04a72..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/signaler..st +++ /dev/null @@ -1,5 +0,0 @@ -updating -signaler: newValue - - "Modify the value of the instance variable 'signaler'." - signaler := newValue \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/signaler.st b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/signaler.st deleted file mode 100644 index 65a6b48..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/instance/signaler.st +++ /dev/null @@ -1,5 +0,0 @@ -accessing -signaler - - "Return the value of the instance variable 'signaler'." - ^signaler \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/methodProperties.json deleted file mode 100644 index 3207dba..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONMappingNotFound.class/methodProperties.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "class" : { - "signalFor:in:" : "PaulDeBruicker 11/01/2014 13:25" }, - "instance" : { - "collection" : "PaulDeBruicker 11/01/2014 13:27", - "collection:" : "PaulDeBruicker 11/01/2014 13:27", - "messageText" : "PaulDeBruicker 11/01/2014 13:30", - "object" : "PaulDeBruicker 11/01/2014 13:27", - "object:" : "PaulDeBruicker 11/01/2014 13:27", - "signaler" : "PaulDeBruicker 11/01/2014 13:27", - "signaler:" : "PaulDeBruicker 11/01/2014 13:27", - "standardMessageText" : "SvenVanCaekenberghe 6/12/2012 15:47" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/initialize.st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/initialize.st deleted file mode 100644 index 0a5b43c..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/initialize.st +++ /dev/null @@ -1,4 +0,0 @@ -initialize-release -initialize - super initialize. - properties := Dictionary new. \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessors..st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessors..st deleted file mode 100644 index c465b85..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAccessors..st +++ /dev/null @@ -1,4 +0,0 @@ -mapping -mapAccessors: accessors - accessors do: [ :each | - self mapAccessor: each ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAllInstVars.st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAllInstVars.st deleted file mode 100644 index b54e25b..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapAllInstVars.st +++ /dev/null @@ -1,3 +0,0 @@ -convenience -mapAllInstVars - self mapInstVars: subjectClass allInstVarNames \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar.to..st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar.to..st deleted file mode 100644 index b2ff072..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVar.to..st +++ /dev/null @@ -1,10 +0,0 @@ -mapping -mapInstVar: instVarName to: propertyName - | index | - index := subjectClass - instVarIndexFor: instVarName asString - ifAbsent: [ self error: 'Inst var not found: ' , instVarName printString ]. - ^ self - mapProperty: propertyName asString - getter: [ :object | object instVarAt: index ] - setter: [ :object :value | object instVarAt: index put: value ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars..st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars..st deleted file mode 100644 index f098c59..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars..st +++ /dev/null @@ -1,4 +0,0 @@ -mapping -mapInstVars: instVarNames - instVarNames do: [ :each | - self mapInstVar: each ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars.st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars.st deleted file mode 100644 index afc5979..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapInstVars.st +++ /dev/null @@ -1,3 +0,0 @@ -convenience -mapInstVars - self mapInstVars: subjectClass instVarNames \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapProperty.getter.setter..st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapProperty.getter.setter..st deleted file mode 100644 index 2d9cb3a..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/mapProperty.getter.setter..st +++ /dev/null @@ -1,10 +0,0 @@ -mapping -mapProperty: propertyName getter: readBlock setter: writeBlock - | propertyMapping | - propertyMapping := NeoJSONPropertyMapping new. - propertyMapping - propertyName: propertyName asSymbol; - getter: readBlock; - setter: writeBlock. - properties at: propertyName put: propertyMapping. - ^ propertyMapping \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/propertyNamed.ifAbsent..st b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/propertyNamed.ifAbsent..st deleted file mode 100644 index 1fd204e..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/instance/propertyNamed.ifAbsent..st +++ /dev/null @@ -1,3 +0,0 @@ -accessing -propertyNamed: propertyName ifAbsent: block - ^ properties at: propertyName ifAbsent: block \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/methodProperties.json deleted file mode 100644 index 70952a0..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONObjectMapping.class/methodProperties.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "identifier" : "SvenVanCaekenberghe 3/23/2014 19:25", - "initialize" : "SvenVanCaekenberghe 6/5/2012 22:50", - "mapAccessor:" : "SvenVanCaekenberghe 6/12/2012 13:13", - "mapAccessor:mutator:to:" : "SvenVanCaekenberghe 6/12/2012 13:12", - "mapAccessor:to:" : "SvenVanCaekenberghe 6/12/2012 13:13", - "mapAccessors:" : "SvenVanCaekenberghe 6/12/2012 13:14", - "mapAllInstVars" : "SvenVanCaekenberghe 6/6/2012 16:00", - "mapInstVar:" : "SvenVanCaekenberghe 6/9/2012 18:37", - "mapInstVar:to:" : "PaulDeBruicker 11/02/2014 19:13", - "mapInstVars" : "SvenVanCaekenberghe 6/6/2012 15:59", - "mapInstVars:" : "SvenVanCaekenberghe 6/6/2012 16:00", - "mapProperty:getter:setter:" : "PaulDeBruicker 11/02/2014 18:32", - "propertyNamed:ifAbsent:" : "PaulDeBruicker 11/02/2014 18:53", - "readFrom:" : "PaulDeBruicker 11/02/2014 19:36", - "subjectClass:" : "SvenVanCaekenberghe 6/6/2012 15:32", - "writeObject:on:" : "SvenVanCaekenberghe 6/6/2012 14:55" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONParseError.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONParseError.class/methodProperties.json deleted file mode 100644 index 0e4a662..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONParseError.class/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName..st b/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName..st deleted file mode 100644 index 91f9ff5..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/propertyName..st +++ /dev/null @@ -1,3 +0,0 @@ -accessing -propertyName: string - propertyName := string \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/writeObject.on..st b/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/writeObject.on..st deleted file mode 100644 index 603cdc1..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/instance/writeObject.on..st +++ /dev/null @@ -1,6 +0,0 @@ -writing -writeObject: anObject on: jsonMapWriter - | value | - value := getter value: anObject. - value - ifNotNil: [ jsonMapWriter writeKey: propertyName value: value as: valueSchema ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/methodProperties.json deleted file mode 100644 index 8bd2fd9..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONPropertyMapping.class/methodProperties.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "getter:" : "SvenVanCaekenberghe 6/6/2012 15:34", - "printOn:" : "SvenVanCaekenberghe 7/4/2013 19:07", - "propertyName:" : "SvenVanCaekenberghe 6/6/2012 15:34", - "readObject:from:" : "SvenVanCaekenberghe 6/8/2012 17:04", - "setter:" : "SvenVanCaekenberghe 6/6/2012 15:34", - "valueSchema:" : "SvenVanCaekenberghe 6/8/2012 17:01", - "writeObject:on:" : "SvenVanCaekenberghe 3/23/2014 21:55" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex.st b/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex.st deleted file mode 100644 index a070376..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseCharacterHex.st +++ /dev/null @@ -1,14 +0,0 @@ -parsing -parseCharacterHex - | value | - value := self parseCharacterHexDigit. - 3 timesRepeat: [ value := (value << 4) + self parseCharacterHexDigit ]. - (value >= 16rD800 and: [ value <= 16rDFFF ]) - ifTrue: [ - | leadingBits trailingBits | - "UTF-16 surrogate pair handling see NeoJSONWriter>>escapeCharacter:" - leadingBits := value - 16rD800 << 10. - trailingBits := self parseTrailingSurrogateHex - 16rDC00 bitAnd: 16r3FF. - value := leadingBits + trailingBits. - value := value + 16r010000 ]. - ^ Character codePoint: value \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseString.st b/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseString.st deleted file mode 100644 index a54ff8f..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/instance/parseString.st +++ /dev/null @@ -1,10 +0,0 @@ -parsing -parseString - | result | - self expectChar: $". - result := self - stringStreamContents: [ :stream | - [ readStream atEnd or: [ readStream peek = $" ] ] - whileFalse: [ stream nextPut: self parseCharacter ] ]. - self expectChar: $". - ^ result \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONReader.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONReader.class/methodProperties.json deleted file mode 100644 index b3ff81e..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONReader.class/methodProperties.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "class" : { - "fromString:" : "SvenVanCaekenberghe 6/9/2012 18:26", - "fromString:as:" : "SvenVanCaekenberghe 6/9/2012 18:30", - "on:" : "SvenVanCaekenberghe 6/13/2012 16:10" }, - "instance" : { - "atEnd" : "SvenVanCaekenberghe 3/6/2013 14:46", - "close" : "SvenVanCaekenberghe 6/2/2012 13:50", - "consumeWhitespace" : "SvenVanCaekenberghe 6/2/2012 21:26", - "error:" : "SvenVanCaekenberghe 6/12/2012 15:54", - "expectChar:" : "SvenVanCaekenberghe 6/2/2012 14:01", - "initialize" : "SvenVanCaekenberghe 6/13/2012 09:39", - "listClass" : "SvenVanCaekenberghe 6/13/2012 09:37", - "listClass:" : "SvenVanCaekenberghe 6/13/2012 09:38", - "mapClass" : "SvenVanCaekenberghe 6/13/2012 09:37", - "mapClass:" : "SvenVanCaekenberghe 6/13/2012 09:38", - "match:do:" : "SvenVanCaekenberghe 12/3/2012 10:57", - "matchChar:" : "SvenVanCaekenberghe 12/3/2012 10:51", - "next" : "SvenVanCaekenberghe 6/7/2012 16:56", - "nextAs:" : "SvenVanCaekenberghe 6/7/2012 22:21", - "on:" : "SvenVanCaekenberghe 6/13/2012 16:10", - "parseCharacter" : "SvenVanCaekenberghe 6/7/2012 16:59", - "parseCharacterHex" : "dkh 11/25/2014 16:41", - "parseCharacterHexDigit" : "SvenVanCaekenberghe 6/2/2012 14:21", - "parseConstantDo:" : "SvenVanCaekenberghe 6/2/2012 14:16", - "parseList" : "SvenVanCaekenberghe 6/7/2012 17:17", - "parseListDo:" : "SvenVanCaekenberghe 6/7/2012 17:15", - "parseListElementsDo:" : "SvenVanCaekenberghe 6/7/2012 17:16", - "parseMap" : "SvenVanCaekenberghe 6/7/2012 17:23", - "parseMapDo:" : "SvenVanCaekenberghe 6/7/2012 17:23", - "parseMapKeysAndValuesDo:" : "SvenVanCaekenberghe 6/7/2012 17:22", - "parseMapKeysDo:" : "SvenVanCaekenberghe 6/7/2012 17:23", - "parseNumber" : "SvenVanCaekenberghe 12/3/2012 11:08", - "parseNumberExponent" : "SvenVanCaekenberghe 12/3/2012 11:08", - "parseNumberFraction" : "SvenVanCaekenberghe 6/2/2012 14:00", - "parseNumberInteger" : "SvenVanCaekenberghe 6/12/2012 16:15", - "parsePropertyName" : "SvenVanCaekenberghe 6/13/2012 09:40", - "parseString" : "dkh 11/25/2014 15:33", - "parseTrailingSurrogateHex" : "dkh 11/25/2014 16:14", - "parseValue" : "SvenVanCaekenberghe 6/12/2012 15:56", - "propertyNamesAsSymbols:" : "SvenVanCaekenberghe 6/13/2012 09:39", - "stringStreamContents:" : "SvenVanCaekenberghe 6/7/2012 16:54", - "unescapeChar:" : "SvenVanCaekenberghe 6/7/2012 16:55" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/methodProperties.json deleted file mode 100644 index 7e6faed..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONStreamingWriter.class/methodProperties.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "class" : { - "on:" : "SvenVanCaekenberghe 6/6/2012 15:05" }, - "instance" : { - "initialize" : "SvenVanCaekenberghe 6/6/2012 14:48", - "on:" : "SvenVanCaekenberghe 6/6/2012 14:49", - "wasUsed" : "SvenVanCaekenberghe 6/6/2012 15:00", - "writeElement:" : "SvenVanCaekenberghe 6/6/2012 15:15", - "writeKey:value:" : "SvenVanCaekenberghe 6/6/2012 15:01", - "writeKey:value:as:" : "SvenVanCaekenberghe 3/23/2014 21:53" } } diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/asciiOnly..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/asciiOnly..st deleted file mode 100644 index 8ad846e..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/asciiOnly..st +++ /dev/null @@ -1,3 +0,0 @@ -initialize-release -asciiOnly: boolean - asciiOnly := boolean \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value..st deleted file mode 100644 index c758a10..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value..st +++ /dev/null @@ -1,7 +0,0 @@ -private -encodeKey: key value: value - self nextPut: key. - self prettyPrintSpace. - writeStream nextPut: $:. - self prettyPrintSpace. - self nextPut: value \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value.as..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value.as..st deleted file mode 100644 index 88e6699..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/encodeKey.value.as..st +++ /dev/null @@ -1,7 +0,0 @@ -private -encodeKey: key value: value as: valueSchema - self nextPut: key. - self prettyPrintSpace. - writeStream nextPut: $:. - self prettyPrintSpace. - self nextPut: value as: valueSchema \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeChar..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeChar..st deleted file mode 100644 index 8a2d3a9..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/escapeChar..st +++ /dev/null @@ -1,45 +0,0 @@ -private -escapeChar: code - code = 34 - ifTrue: [ ^ writeStream nextPutAll: '\"' ]. - code = 92 - ifTrue: [ ^ writeStream nextPutAll: '\\' ]. - code = 47 - ifTrue: [ ^ writeStream nextPutAll: '\/' ]. - code = 8 - ifTrue: [ ^ writeStream nextPutAll: '\b' ]. - code = 12 - ifTrue: [ ^ writeStream nextPutAll: '\f' ]. - code = 10 - ifTrue: [ ^ writeStream nextPutAll: '\n' ]. - code = 13 - ifTrue: [ ^ writeStream nextPutAll: '\r' ]. - code = 9 - ifTrue: [ ^ writeStream nextPutAll: '\t' ]. - code > 16rffff - ifTrue: [ - | x leadingSurrogate trailingSurrogate | - "surrogate pair handling from http://en.wikipedia.org/wiki/UTF-16: -Code points from the other planes (called Supplementary Planes) are encoded in UTF-16 by pairs of 16-bit code units called surrogate pairs, by the following scheme: - - 0x010000 is subtracted from the code point, leaving a 20-bit number in the range 0..0x0FFFFF. - - - The top ten bits (a number in the range 0..0x03FF) are added to 0xD800 to give the first code unit or high surrogate, which will be in the range 0xD800..0xDBFF. - - The low ten bits (also in the range 0..0x03FF) are added to 0xDC00 to give the second code unit or low surrogate, which will be in the range 0xDC00..0xDFFF. - -(High and low surrogates are also known as 'leading' and 'trailing' surrogates, respectively, analogous to the leading and trailing bytes of UTF-8.[3] Note that 'high' surrogates have lower code-point numbers than 'low' surrogates.) - -Since the ranges for the high surrogates, low surrogates, and valid BMP characters are disjoint, searches are simplified: it is not possible for part of one character to match a different part of another character. It also means that UTF-16 is self-synchronizing on 16-bit words: whether a code unit starts a character can be determined without examining earlier code units. UTF-8 shares these advantages, but many earlier multi-byte encoding schemes did not allow unambiguous searching and could only be synchronized by re-parsing from the start of the string. UTF-16 is not self-synchronizing if one byte is lost or if traversal starts at a random byte. - -Because the most commonly used characters are all in the Basic Multilingual Plane, handling of surrogate pairs is often not thoroughly tested. This leads to persistent bugs and potential security holes, even in popular and well-reviewed application software (e.g. CVE-2008-2938, CVE-2012-2135)" - x := code - 16r010000. - leadingSurrogate := 16rD800 + (x >> 10 bitAnd: 16r3FF). "top ten bits" - trailingSurrogate := 16rDC00 + (x bitAnd: 16r3FF). "bottom ten bits missing end of comment" - writeStream nextPutAll: '\u'. - writeStream - nextPutAll: (leadingSurrogate printPaddedWith: $0 to: 4 base: 16). - writeStream nextPutAll: '\u'. - writeStream - nextPutAll: (trailingSurrogate printPaddedWith: $0 to: 4 base: 16) ] - ifFalse: [ - writeStream nextPutAll: '\u'. - writeStream nextPutAll: (code printPaddedWith: $0 to: 4 base: 16) ] \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/initialize.st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/initialize.st deleted file mode 100644 index c0cf599..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/initialize.st +++ /dev/null @@ -1,7 +0,0 @@ -initialize-release -initialize - super initialize. - self newLine: String cr. - self prettyPrint: false. - self asciiOnly: false. - level := 0 \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newLine..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newLine..st deleted file mode 100644 index 5c734ed..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/newLine..st +++ /dev/null @@ -1,3 +0,0 @@ -initialize-release -newLine: string - newLine := string \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut..st deleted file mode 100644 index 0fc2fc0..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/nextPut..st +++ /dev/null @@ -1,3 +0,0 @@ -accessing -nextPut: anObject - anObject neoJsonOn: self \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeFloat..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeFloat..st deleted file mode 100644 index 9d47313..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeFloat..st +++ /dev/null @@ -1,3 +0,0 @@ -writing -writeFloat: float - float printOn: writeStream \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeString..st b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeString..st deleted file mode 100644 index 1c6e006..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/instance/writeString..st +++ /dev/null @@ -1,5 +0,0 @@ -writing -writeString: string - writeStream nextPut: $". - string do: [ :each | self encodeChar: each ]. - writeStream nextPut: $" \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/methodProperties.json b/repository/Neo-JSON-Core.package/NeoJSONWriter.class/methodProperties.json deleted file mode 100644 index fb4fd82..0000000 --- a/repository/Neo-JSON-Core.package/NeoJSONWriter.class/methodProperties.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "class" : { - "on:" : "SvenVanCaekenberghe 6/14/2012 09:54", - "toString:" : "SvenVanCaekenberghe 6/9/2012 18:27", - "toStringPretty:" : "SvenVanCaekenberghe 6/9/2012 18:28" }, - "instance" : { - "asciiOnly:" : "SvenVanCaekenberghe 9/3/2013 12:00", - "close" : "SvenVanCaekenberghe 6/2/2012 22:06", - "doesCodePointNeedEscaping:" : "SvenVanCaekenberghe 9/3/2013 11:58", - "encodeChar:" : "SvenVanCaekenberghe 9/3/2013 11:55", - "encodeKey:value:" : "SvenVanCaekenberghe 6/3/2012 19:41", - "encodeKey:value:as:" : "SvenVanCaekenberghe 3/23/2014 21:53", - "escapeChar:" : "dkh 11/25/2014 16:36", - "indentedDo:" : "SvenVanCaekenberghe 6/3/2012 19:31", - "initialize" : "dkh 11/25/2014 15:36", - "listElementSeparator" : "SvenVanCaekenberghe 6/3/2012 19:32", - "mapElementSeparator" : "SvenVanCaekenberghe 6/3/2012 19:32", - "newLine:" : "SvenVanCaekenberghe 12/10/2012 16:27", - "newline" : "SvenVanCaekenberghe 4/17/2014 11:58", - "newlineIndent" : "SvenVanCaekenberghe 4/17/2014 11:55", - "nextPut:" : "SvenVanCaekenberghe 6/2/2012 22:11", - "nextPut:as:" : "SvenVanCaekenberghe 3/23/2014 21:57", - "on:" : "SvenVanCaekenberghe 6/14/2012 09:54", - "prettyPrint:" : "SvenVanCaekenberghe 6/2/2012 22:06", - "prettyPrintSpace" : "SvenVanCaekenberghe 12/10/2012 16:33", - "writeBoolean:" : "SvenVanCaekenberghe 6/2/2012 22:18", - "writeFloat:" : "SvenVanCaekenberghe 6/2/2012 22:19", - "writeInteger:" : "SvenVanCaekenberghe 6/2/2012 22:18", - "writeList:" : "SvenVanCaekenberghe 6/6/2012 15:20", - "writeListStreamingDo:" : "SvenVanCaekenberghe 6/6/2012 15:19", - "writeMap:" : "SvenVanCaekenberghe 6/6/2012 15:04", - "writeMapStreamingDo:" : "SvenVanCaekenberghe 6/6/2012 15:19", - "writeNull" : "SvenVanCaekenberghe 6/2/2012 22:15", - "writeObject:" : "SvenVanCaekenberghe 6/7/2012 15:55", - "writeStreamingDo:" : "SvenVanCaekenberghe 6/6/2012 15:19", - "writeString:" : "dkh 11/25/2014 15:36" } } diff --git a/repository/Neo-JSON-Core.package/Number.extension/methodProperties.json b/repository/Neo-JSON-Core.package/Number.extension/methodProperties.json deleted file mode 100644 index b55faec..0000000 --- a/repository/Neo-JSON-Core.package/Number.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "SvenVanCaekenberghe 6/2/2012 22:17" } } diff --git a/repository/Neo-JSON-Core.package/Object.extension/methodProperties.json b/repository/Neo-JSON-Core.package/Object.extension/methodProperties.json deleted file mode 100644 index 0e240ef..0000000 --- a/repository/Neo-JSON-Core.package/Object.extension/methodProperties.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "instVarIndexFor:ifAbsent:" : "PaulDeBruicker 11/01/2014 20:43", - "neoJsonOn:" : "SvenVanCaekenberghe 6/5/2012 22:29" } } diff --git a/repository/Neo-JSON-Core.package/UndefinedObject.extension/methodProperties.json b/repository/Neo-JSON-Core.package/UndefinedObject.extension/methodProperties.json deleted file mode 100644 index a894ee8..0000000 --- a/repository/Neo-JSON-Core.package/UndefinedObject.extension/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "neoJsonOn:" : "SvenVanCaekenberghe 6/2/2012 22:15" } } diff --git a/repository/Neo-JSON-Core.package/monticello.meta/categories.st b/repository/Neo-JSON-Core.package/monticello.meta/categories.st deleted file mode 100644 index 9cba366..0000000 --- a/repository/Neo-JSON-Core.package/monticello.meta/categories.st +++ /dev/null @@ -1 +0,0 @@ -SystemOrganization addCategory: #'Neo-JSON-Core'! diff --git a/repository/Neo-JSON-Core.package/monticello.meta/package b/repository/Neo-JSON-Core.package/monticello.meta/package deleted file mode 100644 index 657f530..0000000 --- a/repository/Neo-JSON-Core.package/monticello.meta/package +++ /dev/null @@ -1 +0,0 @@ -(name 'Neo-JSON-Core') \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/monticello.meta/version b/repository/Neo-JSON-Core.package/monticello.meta/version deleted file mode 100644 index 398f11e..0000000 --- a/repository/Neo-JSON-Core.package/monticello.meta/version +++ /dev/null @@ -1 +0,0 @@ -(name 'Neo-JSON-Core-dkh.33' message 'Issue #5: turns out that what was missing from the NeoJSON implementation was the handling of code points greater than 0xFFFF (as noted in my original comment) ... I had misinterpretted the solution to be to use UTF8 encoding ... the proper answer was to use UTF-16 surrogate pairs for code points > 16rFFFF... which I''ve done ' id '262e5ad7-dd42-48aa-869d-05ffd6021def' date '11/25/2014' time '16:50:14' author 'dkh' ancestors ((name 'Neo-JSON-Core-dkh.32' message 'Issue #5: expand test suite to cover Unicode16 and Unicode32 strings. Move String>>neoJsonOn: to CharacterCollection>>neoJsonOn: so that multi-byte strings are covered. Unicode32 string test cases are failing: 74 run, 71 passes, 0 expected defects, 3 failures, 0 errors, 0 unexpected passes 75 tests 74 run [''done''] 71 passes 0 expected defects 3 failures 0 errors 0 unexpected passes ' id '5e565bf6-4a97-4314-a35f-c7edd0b8804c' date '11/24/2014' time '22:46:28' author 'dkh' ancestors ((name 'Neo-JSON-Core-dkh.31' message 'tests should be green now ...' id '50a08add-a37e-412c-ac3a-1f2ece1212f2' date '11/22/2014' time '09:52:41' author 'dkh' ancestors ((name 'Neo-JSON-Core-dkh.30' message 'move some methods to GsSqueakCommon ... tweak baseline' id 'e3ed0d1f-578b-4ca4-82f5-9649a31d7562' date '11/21/2014' time '21:39:49' author 'dkh' ancestors ((name 'Neo-JSON-Core-PaulDeBruicker.29' message 'All tests but one pass. GemStone does not treat Strings and Symbols that are made up of the same characters as equal. So there may be issues because of that but things seem to work' id '9b3a8d41-6da7-404c-9dd3-b2c4e1820c12' date '11/02/2014' time '19:55:39' author 'PaulDeBruicker' ancestors ((name 'Neo-JSON-Core-PaulDeBruicker.28' message 'stashing changes because I just found the other gemstone port ' id 'f84c7c06-f798-44bd-8ec2-1aca0b57e049' date '11/02/2014' time '19:06:46' author 'PaulDeBruicker' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.27' message 'Added NeoJSONWriter>>#newline to write an end of line on the wrapped stream depending on the #newLine: setting' id '5a262fd6-a42d-4102-b554-26e4f1eade3d' date '04/17/2014' time '12:12:47' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.26' message 'Added new feature NeoJSONWriter>>#nextPutAs: symmetrical to NeoJSONReader>>#next:as: More specifically NeoJSONPropertyMapping>>#writeObjectOn: now respects the valueSchema if it exists using NeoJSONStreamingWriter>>#writeKey:value:as: and NeoJSONWriter>>#encodeKey:value:as: Made both the reader and writer blocks in NeoJSONCustomMapping optional with a fallback to default behavior Refactoring: added NeoJSONMapping abstract superclass above NeoJSONObjectMapping and NeoJSONCustomMapping to better clarify the design' id '41d2075d-bca4-4c08-bdf8-ed0c8da9bcf2' date '03/24/2014' time '12:18:21' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.25' message 'Added basic support for mapping using inheritance when using #neoJonMapping : (see #testObject3) Renamed #new[Custom|Object]MappingFor: to [custom|object]MappingFor: to better reflect the new behavior Thanks Philippe Back for making these suggestions!' id '3051cd7d-a857-4aee-b5ba-d56a4085517b' date '03/22/2014' time '11:03:31' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.24' message 'New feature: NeoJSONWriter>>#asciiOnly: to escape all non ASCII characters in strings' id '9f2d3ef6-abbb-46c1-bce7-95a6bd8b4954' date '09/03/2013' time '12:21:28' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.23' message 'Added NeoJSONCustomMapping>>#mapWithValueSchema:' id '6d0d538b-6fb1-41ac-92ee-05721924c5c4' date '08/30/2013' time '11:09:17' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.22' message 'Fix more double dots in the source code of #printOn: that hampered Gemstone compatibility (thx Sebastian Heidbrink)' id 'd15895fc-5743-4ec8-b99f-76fa5f72baf4' date '07/04/2013' time '07:25:56' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.21' message 'Fix a double dot in the source code of NeoJSONCustomWrapper>>#printOn: that hampered Gemstone compatibility (thx Sebastian Heidbrink)' id '3fcb3755-32a9-4c17-ac08-6721bf37a301' date '07/04/2013' time '06:41:52' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.20' message 'Added NeoJSONReader>>#atEnd' id 'afd8e136-e594-4bef-ad4b-7d3bc48fc36e' date '03/06/2013' time '03:24:11' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.19' message 'added NeoJSONWriter>>#newLine: to customize the end of line convention when pretty printing' id 'bf3e7e59-8300-44a6-889e-1f866c8d2977' date '12/10/2012' time '05:11:36' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.18' message 'minor refactoring using #peekFor:' id 'e1330b1e-87f4-4ea3-b81c-5deb03652c0d' date '12/03/2012' time '11:10:22' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.17' message 'modified by accident, not really changed' id 'a18f519f-c220-4ea1-a6bb-163e2c70eab7' date '06/14/2012' time '10:01:07' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.16' message 'documented the character stream API being used' id '5ba3bcd2-e7a6-4b07-91af-af04c7f98624' date '06/13/2012' time '04:29:08' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.15' message 'bugfix in NeoJSONReader>>#match:do: added examples to class comments' id '89ad4ee7-3035-43af-9d5c-cbbef6bcb3f0' date '06/13/2012' time '02:58:00' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.14' message 'extended NeoJSONReader with settable listClass and mapClass as well as a propertyNamesAsSymbols option extended class and method comments' id '3f749c2c-b53b-4d56-bb65-bfe964b5a69b' date '06/13/2012' time '11:56:19' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.13' message 'made NeoJSONReader>>parseNumberInteger more strict' id '5233f22a-8653-43c2-8651-bf5fa274b3da' date '06/12/2012' time '04:19:27' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.12' message 'introduced some custom exceptions' id 'bb6ec6aa-4e5d-4fac-9aa4-629ea6f068b6' date '06/12/2012' time '03:57:32' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.11' message 'major simplification: removed NeoJSON[Composite|List|Map]Mapping, all to be handled by blocks in NeoJSONCustomMapping renamed forCustom:do: to for:customDo: accessor based mapping to NeoJSONObjectMapping ' id '82a72131-e968-4ffe-af32-60085b4ecc67' date '06/12/2012' time '01:36:03' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.10' message 'optimized NeoJSONWriter>>#encodeChar: to do minimal work' id 'a684bb8c-d2d0-4a4b-8af2-da24c3f5fda4' date '06/10/2012' time '09:27:46' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.9' message 'added NeoJSONTestObject1 with class side #neoJsonMapping: method' id '49129177-ee36-4e4b-890e-314e92f23d76' date '06/09/2012' time '06:56:12' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.8' message 'added custom mapping' id 'b02af4e3-7a91-471f-81a0-57db8b43a87d' date '06/08/2012' time '10:09:41' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.7' message 'adding valueSchema to propertyMapping' id '61c29ad0-e2a6-40af-8360-24952a5e6633' date '06/08/2012' time '20:35:55' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.6' message '1st version where list mapping works on some simple examples' id 'e3250e47-9c16-461e-8d2e-e8031e4cc2be' date '06/08/2012' time '16:40:26' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.5' message 'introduced NeoJSONMapper 1st simplified version of NeoJSONReader>>#nextAs:' id '8a4a2338-c728-4ec5-bae9-8232abd6d7f6' date '06/07/2012' time '15:52:29' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.4' message '1st version with working object mapping for writer' id '0208c7c7-3ab1-4081-9061-9c6ca9d7e7cf' date '06/06/2012' time '20:47:04' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.3' message 'added more tests and a simple benchmark' id '2567c409-eb97-428e-a865-e6d078d23dff' date '06/04/2012' time '18:52:34' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.2' message 'first simple version of NeoJSONWriter' id '7e6474b7-70ed-4cb0-8348-05adddc17853' date '06/03/2012' time '19:57:41' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Core-SvenVanCaekenberghe.1' message 'first simple version of NeoJSONReader' id 'e0039613-c57d-47ae-8838-db64917ca722' date '06/02/2012' time '21:59:42' author 'SvenVanCaekenberghe' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/repository/Neo-JSON-Core.package/properties.json b/repository/Neo-JSON-Core.package/properties.json deleted file mode 100644 index f037444..0000000 --- a/repository/Neo-JSON-Core.package/properties.json +++ /dev/null @@ -1,2 +0,0 @@ -{ - } diff --git a/repository/Neo-JSON-Core/Boolean.extension.st b/repository/Neo-JSON-Core/Boolean.extension.st new file mode 100644 index 0000000..7357183 --- /dev/null +++ b/repository/Neo-JSON-Core/Boolean.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Boolean } + +{ #category : #'*neo-json-core' } +Boolean >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeBoolean: self +] diff --git a/repository/Neo-JSON-Core/Collection.extension.st b/repository/Neo-JSON-Core/Collection.extension.st new file mode 100644 index 0000000..c98f1a5 --- /dev/null +++ b/repository/Neo-JSON-Core/Collection.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Collection } + +{ #category : #'*neo-json-core' } +Collection >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeList: self +] diff --git a/repository/Neo-JSON-Core/Dictionary.extension.st b/repository/Neo-JSON-Core/Dictionary.extension.st new file mode 100644 index 0000000..85fb99f --- /dev/null +++ b/repository/Neo-JSON-Core/Dictionary.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Dictionary } + +{ #category : #'*neo-json-core' } +Dictionary >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeMap: self +] diff --git a/repository/Neo-JSON-Core/Integer.extension.st b/repository/Neo-JSON-Core/Integer.extension.st new file mode 100644 index 0000000..701ccef --- /dev/null +++ b/repository/Neo-JSON-Core/Integer.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Integer } + +{ #category : #'*neo-json-core' } +Integer >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeInteger: self +] diff --git a/repository/Neo-JSON-Core/NeoJSONArray.class.st b/repository/Neo-JSON-Core/NeoJSONArray.class.st new file mode 100644 index 0000000..1282b39 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONArray.class.st @@ -0,0 +1,142 @@ +" +I am NeoJSONArray. +I am an Array. + +I am often used in combination with NeoJSONObject, to represent the result of parsing JSON. + + I support path access for nested instances of me, using #atPath: and #atPath:put: + +Used in its generic way, NeoJSONParser will return Arrays and Dictionaries. +Returning NeoJSONArrays and NeoJSONObjects, simple subclasses, allows to add some convenience methods. + +" +Class { + #name : #NeoJSONArray, + #superclass : #OrderedCollection, + #category : #'Neo-JSON-Core' +} + +{ #category : #example } +NeoJSONArray class >> exampleNumbers [ + + | numbers | + numbers := self new: 128 withAll: nil. + 0 to: 127 do: [ :n | + numbers + at: n + 1 + put: (NeoJSONObject new + integer: n; + decimal: (n printStringBase: 10); + octal: (n printStringBase: 8); + hexadecimal: (n printStringBase: 16); + binary: (n printStringBase: 2); + roman: n printStringRoman; + words: n asWords; + prime: n isPrime; + character: n asCharacter asString) ]. + ^ numbers +] + +{ #category : #example } +NeoJSONArray class >> exampleSimple [ + + ^ self withAll: { 0 . 1 . Float pi. 'string' . true . false. nil } +] + +{ #category : #adding } +NeoJSONArray >> at: index add: object [ + ^ index = '-' + ifTrue: [ self addLast: object ] + ifFalse: [ self insert: object before: index ] +] + +{ #category : #accessing } +NeoJSONArray >> atPath: keyCollection [ + "Use each key in keyCollection recursively, return nil when a key is missing. + Note how keys can also be indexes to arrays." + + | value | + value := self. + keyCollection do: [ :each | + value := value at: each ifAbsent: [ ^ nil ] ]. + ^ value +] + +{ #category : #adding } +NeoJSONArray >> atPath: keyCollection add: newValue [ + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays. + This variant will insert/add to arrays" + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each add: target species new ] ]. + ^ target at: keyCollection last add: newValue +] + +{ #category : #accessing } +NeoJSONArray >> atPath: keyCollection put: newValue [ + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each put: target species new ] ]. + ^ target at: keyCollection last put: newValue +] + +{ #category : #accessing } +NeoJSONArray >> findPath: conditionBlock [ + "Find and return the first path to an object in the graph that I represent + for which conditionBlock holds. Return nil when not found." + + (conditionBlock value: self) ifTrue: [ ^ #(()) ]. + self doWithIndex: [ :value :index | + (conditionBlock value: value) ifTrue: [ ^ { index } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPath: conditionBlock) ifNotNil: [ :subPath | + ^ { index } , subPath ] ] ]. + ^ nil +] + +{ #category : #accessing } +NeoJSONArray >> findPaths: conditionBlock [ + "Find and return all paths to objects in the graph that I represent + for which conditionBlock holds. Return an empty collection when none are found." + + | found | + found := OrderedCollection new. + self doWithIndex: [ :value :index | + (conditionBlock value: value) ifTrue: [ found add: { index } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPaths: conditionBlock) do: [ :subPath | + found add: { index } , subPath ] ] ]. + ^ found +] + +{ #category : #print } +NeoJSONArray >> printOn: stream [ + "I use my JSON representation when printing myself" + + [ (NeoJSONWriter on: stream) nextPut: self ] + on: Error + do: [ :exception | + stream + nextPutAll: ' Error printing JSON: '; + print: exception ] +] + +{ #category : #removing } +NeoJSONArray >> removeKey: index [ + "Polymorphic with NeoJSONObject: remove the element at index" + + ^ self removeAt: index +] diff --git a/repository/Neo-JSON-Core/NeoJSONCustomMapping.class.st b/repository/Neo-JSON-Core/NeoJSONCustomMapping.class.st new file mode 100644 index 0000000..aeb7c3d --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONCustomMapping.class.st @@ -0,0 +1,146 @@ +" +I am NeoJSONCustomMapping. + +I read the next JSON value and turn it into a Smalltalk object using a converter block. +" +Class { + #name : #NeoJSONCustomMapping, + #superclass : #NeoJSONMapping, + #instVars : [ + 'schemaName', + 'reader', + 'writer' + ], + #category : #'Neo-JSON-Core' +} + +{ #category : #mapping } +NeoJSONCustomMapping >> decoder: block [ + "Set a decoder block that accepts the next object representation read + and converts it into the actual object to be returned." + + self reader: [ :jsonReader | | representation | + representation := jsonReader next. + block value: representation ] +] + +{ #category : #mapping } +NeoJSONCustomMapping >> encoder: block [ + "Set a encoder block that accepts the next object to be written + and converts it into the actual representation to be written." + + self writer: [ :jsonWriter :anObject | | representation | + representation := block value: anObject. + jsonWriter nextPut: representation ] +] + +{ #category : #accessing } +NeoJSONCustomMapping >> identifier [ + ^ schemaName +] + +{ #category : #mapping } +NeoJSONCustomMapping >> listOfElementSchema: elementSchema [ + "Set the reader to a block that will create an instance of the + standard listClass while reading a list of elements of type elementSchema. + Pass down the elementSchema to the elements in the writer." + + self reader: [ :jsonReader | + jsonReader listClass streamContents: [ :stream | + jsonReader parseListDo: [ | element | + element := jsonReader nextAs: elementSchema. + stream nextPut: element ] ] ]. + self writer: [ :jsonWriter :list | + jsonWriter writeListStreamingDo: [ :listWriter | + list do: [ :each | + listWriter writeElement: each as: elementSchema ] ] ] +] + +{ #category : #mapping } +NeoJSONCustomMapping >> listOfType: collectionClass [ + "Set the reader to a block that will create an instance of collectionClass + using #streamContents: while reading a list of elements. + Set the writer to write the list's elements." + + self reader: [ :jsonReader | + collectionClass streamContents: [ :stream | + jsonReader parseListDo: [ | element | + element := jsonReader next. + stream nextPut: element ] ] ]. + self writer: [ :jsonWriter :list | + jsonWriter writeListStreamingDo: [ :listWriter | + list do: [ :each | + listWriter writeElement: each ] ] ] +] + +{ #category : #mapping } +NeoJSONCustomMapping >> listOfType: collectionClass andElementSchema: elementSchema [ + "Set the reader to a block that will create an instance of collectionClass + using #streamContents: while reading a list of elements of type elementSchema. + Pass down the elementSchema to the elements in the writer." + + self reader: [ :jsonReader | + collectionClass streamContents: [ :stream | + jsonReader parseListDo: [ | element | + element := jsonReader nextAs: elementSchema. + stream nextPut: element ] ] ]. + self writer: [ :jsonWriter :list | + jsonWriter writeListStreamingDo: [ :listWriter | + list do: [ :each | + listWriter writeElement: each as: elementSchema ] ] ] +] + +{ #category : #mapping } +NeoJSONCustomMapping >> mapWithValueSchema: valueSchema [ + "Set the reader to a block that will create an instance of the + standard mapClass while reading values of type valueSchema, + with standard keys" + + self reader: [ :jsonReader | | map | + map := jsonReader mapClass new. + jsonReader parseMapKeysDo: [ :key | | value | + value := jsonReader nextAs: valueSchema. + map at: key put: value ]. + map ]. + self writer: [ :jsonWriter :map | + jsonWriter writeMapStreamingDo: [ :mapWriter | + map keysAndValuesDo: [ :key :value | + mapWriter writeKey: key value: value as: valueSchema ] ] ] +] + +{ #category : #parsing } +NeoJSONCustomMapping >> readFrom: jsonReader [ + ^ reader + ifNil: [ jsonReader next ] + ifNotNil: [ reader value: jsonReader ] +] + +{ #category : #accessing } +NeoJSONCustomMapping >> reader: block [ + "Set the reader to block, a 1 argument block that when given + a jsonReader as argument reads the object that I represent. + When there is no reader block, the default #next will be used." + + reader := block +] + +{ #category : #accessing } +NeoJSONCustomMapping >> schemaName: schema [ + schemaName := schema +] + +{ #category : #writing } +NeoJSONCustomMapping >> writeObject: anObject on: jsonWriter [ + writer + ifNil: [ anObject neoJsonOn: jsonWriter ] + ifNotNil: [ writer value: jsonWriter value: anObject ] +] + +{ #category : #accessing } +NeoJSONCustomMapping >> writer: block [ + "Set the writer to block, a 2 argument block that when given: a jsonWriter + and the object to write will write the object that I represent. + When there is no writer block, the default #neoJsonOn: will be used." + + writer := block +] diff --git a/repository/Neo-JSON-Core/NeoJSONFloatPrinter.class.st b/repository/Neo-JSON-Core/NeoJSONFloatPrinter.class.st new file mode 100644 index 0000000..0b22f3e --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONFloatPrinter.class.st @@ -0,0 +1,178 @@ +" +I am NeoJSONFloatPrinter. + +I print Float numbers in a compact, human friendly format. + +The following (default) parameters are used: + - base 10 - hardcoded (for now) + - precision 5 digits + - decimal point - hardcoded (for now) + - exponent e - hardcoded (for now) + - NaN, Inf and -Inf - hardcoded (for now) + - lower 1e-4 + - upper 1e6 + - decimal notation for abs values inside abs [ lower, upper ] + - scientific notation for abs values outside [ lower, upper ] + - no padding, no trailing zeros in fraction part + - only negative sign, never a positive sign + - no thousands separators + - no engineering notation + +See my class side for configuration examples. + +My public interface is in the printing protocol. + +" +Class { + #name : #NeoJSONFloatPrinter, + #superclass : #Object, + #instVars : [ + 'precision', + 'lower', + 'upper', + 'base' + ], + #category : #'Neo-JSON-Core' +} + +{ #category : #'instance creation' } +NeoJSONFloatPrinter class >> lowPrecision [ + ^ self new + precision: 2; + lower: 1e-2; + upper: 1e5; + yourself +] + +{ #category : #'instance creation' } +NeoJSONFloatPrinter class >> scientificOnly [ + ^ self new + lower: 0; + upper: 0; + yourself +] + +{ #category : #constants } +NeoJSONFloatPrinter >> decimalPoint [ + ^ $. +] + +{ #category : #constants } +NeoJSONFloatPrinter >> exponent [ + ^ $e +] + +{ #category : #constants } +NeoJSONFloatPrinter >> infinite [ + ^ 'Inf' +] + +{ #category : #'initialize-release' } +NeoJSONFloatPrinter >> initialize [ + super initialize. + base := 10. + precision := 5. + lower := 1e-4. + upper := 1e6 +] + +{ #category : #'initialize-release' } +NeoJSONFloatPrinter >> lower: number [ + lower := number +] + +{ #category : #constants } +NeoJSONFloatPrinter >> nan [ + ^ 'NaN' +] + +{ #category : #'initialize-release' } +NeoJSONFloatPrinter >> precision: numberOfDigits [ + self assert: (numberOfDigits between: 1 and: 20). + precision := numberOfDigits +] + +{ #category : #printing } +NeoJSONFloatPrinter >> print: float [ + ^ String new: 16 streamContents: [ :out | + self print: float on: out ] +] + +{ #category : #private } +NeoJSONFloatPrinter >> print: float decimalOn: stream [ + stream print: float asInteger. + stream nextPut: self decimalPoint. + self + print: (float fractionPart * (base raisedTo: precision)) rounded + fractionOn: stream +] + +{ #category : #private } +NeoJSONFloatPrinter >> print: fractionPart fractionOn: stream [ + | zeros | + zeros := 0. "leading zeros are significant, trailing zeros are not printed" + precision to: 1 by: -1 do: [ :position | | digit | + digit := fractionPart digitAt: position base: base. + digit = 0 + ifTrue: [ zeros := zeros +1 ] + ifFalse: [ + zeros > 0 ifTrue: [ + zeros timesRepeat: [ stream nextPut: $0 ]. + zeros := 0 ]. + stream nextPut: digit asCharacterDigit ] ] +] + +{ #category : #printing } +NeoJSONFloatPrinter >> print: float on: stream [ + | int abs | + (float isZero or: [ float isFinite not ]) + ifTrue: [ ^ self print: float specialOn: stream ]. + self print: float signOn: stream. + ((abs := float abs) between: lower and: upper) + ifTrue: [ + (int := abs asInteger) = abs + ifTrue: [ int printOn: stream ] + ifFalse: [ self print: abs decimalOn: stream ] ] + ifFalse: [ self print: abs scientificOn: stream ] +] + +{ #category : #private } +NeoJSONFloatPrinter >> print: float scientificOn: stream [ + | exponent mantissa | + exponent := (float ln / base ln) floor. + mantissa := float / (base raisedTo: exponent). + self print: mantissa decimalOn: stream. + stream + nextPut: self exponent; + print: exponent +] + +{ #category : #private } +NeoJSONFloatPrinter >> print: float signOn: stream [ + float sign = -1 + ifTrue: [ stream nextPut: $- ] +] + +{ #category : #private } +NeoJSONFloatPrinter >> print: float specialOn: stream [ + float isZero + ifTrue: [ + stream nextPut: $0 ] + ifFalse: [ + float isNaN + ifTrue: [ + stream nextPutAll: self nan ] + ifFalse: [ + self print: float signOn: stream. + stream nextPutAll: self infinite ] ] +] + +{ #category : #printing } +NeoJSONFloatPrinter >> printFloat: float on: stream [ + self print: float on: stream +] + +{ #category : #'initialize-release' } +NeoJSONFloatPrinter >> upper: number [ + upper := number +] diff --git a/repository/Neo-JSON-Core/NeoJSONMapper.class.st b/repository/Neo-JSON-Core/NeoJSONMapper.class.st new file mode 100644 index 0000000..ca85a63 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONMapper.class.st @@ -0,0 +1,130 @@ +" +I am NeoJSONMapper. +I hold a mapping from schema identifiers to objects that known how to read or write instances from or to JSON. + +Schema identifiers are either Smalltalk classes or Symbols. + +I offer a builder interface to construct mappings. + +The standard object mapping represents a Smalltalk object as a map, mapping some or all instance variables, or a set of accessors (getter/setter methods). Furthermore, for each value an optional schema can be specified. + +Using a custom mapping, a reader and/or writer block can deal with special cases such as specific collection types with an optional schema for the elements, or a direct mapping of semi primitive types such as Date or DateAndTime. + +A mapping can be specified explicitely on a mapper, or can be resolved using the #neoJsonMapping: class method. + +Here are some examples: + + mapper mapAllInstVarsFor: Point. + mapper for: TestObject do: [ :mapping | + mapping mapInstVars: #(id name). + (mapping mapInstVar: #timestamp to: 'created-at') valueSchema: DateAndTime. + (mapping mapInstVar: #points) valueSchema: #ArrayOfPoints. + (mapping mapInstVar: #bytes) valueSchema: ByteArray ]. + mapper for: DateAndTime customDo: [ :mapping | + mapping decoder: [ :string | DateAndTime fromString: string ]. + mapping encoder: [ :dateAndTime | dateAndTime printString ] ]. + mapper for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]. + mapper for: ByteArray customDo: [ :mapping | + mapping listOfType: ByteArray ] + +" +Class { + #name : #NeoJSONMapper, + #superclass : #Object, + #instVars : [ + 'mappings' + ], + #category : 'Neo-JSON-Core' +} + +{ #category : #private } +NeoJSONMapper >> customMappingFor: schemaName [ + ^ self mappings + at: schemaName + ifAbsentPut: [ + NeoJSONCustomMapping new + schemaName: schemaName; + yourself ] +] + +{ #category : #mapping } +NeoJSONMapper >> for: schemaName customDo: block [ + "Execute the code in block to further customize the mapping for schemaName. + Create and add a new custom mapping for schemaName if necessary." + + | mapping | + mapping := self customMappingFor: schemaName. + block value: mapping. + ^ mapping +] + +{ #category : #mapping } +NeoJSONMapper >> for: smalltalkClass do: block [ + "Execute the code in block to further customize the mapping for schemaName. + Create and add a new standard object mapping for schemaName if necessary." + + | mapping | + mapping := self objectMappingFor: smalltalkClass. + block value: mapping. + ^ mapping +] + +{ #category : #convencience } +NeoJSONMapper >> mapAllInstVarsFor: smalltalkClass [ + "Map the instance variables of smalltalkClass and all its super classes" + + | mapping | + mapping := self objectMappingFor: smalltalkClass. + mapping mapAllInstVars. + ^ mapping +] + +{ #category : #convencience } +NeoJSONMapper >> mapInstVarsFor: smalltalkClass [ + "Map the instance variables of smalltalkClass" + + | mapping | + mapping := self objectMappingFor: smalltalkClass. + mapping mapInstVars. + ^ mapping +] + +{ #category : #accessing } +NeoJSONMapper >> mappingFor: schema [ + ^ self + mappingFor: schema + ifAbsent: [ NeoJSONMappingNotFound signalFor: schema in: self ] +] + +{ #category : #accessing } +NeoJSONMapper >> mappingFor: schema ifAbsent: block [ + (self mappings includesKey: schema) + ifFalse: [ self resolveMappingFor: schema ]. + ^ self mappings + at: schema + ifAbsent: block +] + +{ #category : #private } +NeoJSONMapper >> mappings [ + ^ mappings + ifNil: [ mappings := Dictionary new ] +] + +{ #category : #private } +NeoJSONMapper >> objectMappingFor: smalltalkClass [ + ^ self mappings + at: smalltalkClass + ifAbsentPut: [ + NeoJSONObjectMapping new + subjectClass: smalltalkClass; + yourself ] +] + +{ #category : #private } +NeoJSONMapper >> resolveMappingFor: class [ + (class respondsTo: #neoJsonMapping:) + ifTrue: [ + class perform: #neoJsonMapping: with: self ] +] diff --git a/repository/Neo-JSON-Core/NeoJSONMapping.class.st b/repository/Neo-JSON-Core/NeoJSONMapping.class.st new file mode 100644 index 0000000..019f11b --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONMapping.class.st @@ -0,0 +1,30 @@ +" +I am NeoJSONMapping, an abstract superclass for mapping definitions. + +" +Class { + #name : #NeoJSONMapping, + #superclass : #Object, + #category : 'Neo-JSON-Core' +} + +{ #category : #accessing } +NeoJSONMapping >> identifier [ + self subclassResponsibility +] + +{ #category : #printing } +NeoJSONMapping >> printOn: stream [ + super printOn: stream. + stream nextPut: $(; print: self identifier; nextPut: $) +] + +{ #category : #parsing } +NeoJSONMapping >> readFrom: jsonReader [ + self subclassResponsibility +] + +{ #category : #writing } +NeoJSONMapping >> writeObject: anObject on: jsonWriter [ + self subclassResponsibility +] diff --git a/repository/Neo-JSON-Core/NeoJSONMappingNotFound.class.st b/repository/Neo-JSON-Core/NeoJSONMappingNotFound.class.st new file mode 100644 index 0000000..cf8a6a1 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONMappingNotFound.class.st @@ -0,0 +1,77 @@ +" +I am NeoJSONMappingNotFound. I am signalled when no mapping is found for a schema. + +Portability comment: In Pharo, I could technically subclass from NotFound directly, avoid all my defined methods and only keep #messageText and #standardMessageText. However, NotFound exception does not exist in other dialects. To keep NeoJSON as portable as possible we duplicate some Pharo code into myself. +" +Class { + #name : #NeoJSONMappingNotFound, + #superclass : #Error, + #instVars : [ + 'object', + 'collection' + ], + #category : 'Neo-JSON-Core' +} + +{ #category : #'instance creation' } +NeoJSONMappingNotFound class >> signalFor: anObject [ + "Create and signal an exception for anObject in the default receiver." + + ^ self new + object: anObject; + signal +] + +{ #category : #'instance creation' } +NeoJSONMappingNotFound class >> signalFor: anObject in: aCollection [ + "Create and signal an exception for anObject in aCollection." + + ^ self new + object: anObject; + collection: aCollection; + signal +] + +{ #category : #accessing } +NeoJSONMappingNotFound >> collection [ + "Return the collection where something is not found in" + + ^ collection +] + +{ #category : #accessing } +NeoJSONMappingNotFound >> collection: aCollection [ + "Set the collection where something is not found in" + + collection := aCollection +] + +{ #category : #accessing } +NeoJSONMappingNotFound >> messageText [ + "Overwritten with standard text. To ease portability to other Smalltalk dialects we do not access the instVar 'messageText' as not all dialects have it. Not caching the value on the instVar shouldn't bring any performance hit in this case. " + + ^ self standardMessageText +] + +{ #category : #accessing } +NeoJSONMappingNotFound >> object [ + "Return the object that was not found" + + ^ object +] + +{ #category : #accessing } +NeoJSONMappingNotFound >> object: anObject [ + "Set the object that was not found" + + object := anObject +] + +{ #category : #private } +NeoJSONMappingNotFound >> standardMessageText [ + ^ String streamContents: [ :stream | + stream << 'No mapping found for '. + stream print: self object. + stream << ' in '. + stream print: self collection class ] +] diff --git a/repository/Neo-JSON-Core/NeoJSONObject.class.st b/repository/Neo-JSON-Core/NeoJSONObject.class.st new file mode 100644 index 0000000..883b4d1 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONObject.class.st @@ -0,0 +1,341 @@ +" +I am NeoJSONObject. +I am an OrderedDictionary. + +I behave more like a JavaScript object. I return nil for missing keys. I allow any property to be read or set by using a normal accessor message. + +The following are equivalent: + + self foo. + self at: #foo. + +As are the following + + self foo: 1. + self at: #foo put: 1. + +Except that in the first case, self is returned. + +I can optionally be used by NeoJSONReader as mapClass (see #mapClass:). + +For output, I act just like my superclass (it is thus not necessary to do any conversions). + +Example: + + NeoJSONObject fromString: '{""foo"":1,""bar"":-2}'. + NeoJSONObject new foo: 1; bar: -2. + { #x -> 100. #y -> 200 } as: NeoJSONObject. + (NeoJSONObject new data: (NeoJSONObject new id: #sensor1; value: 37.5)) asString. + +I use JSON as my printed representation. To convert me to JSON, use #printString or #asString. + +Additionally, I support path access for nested instances of me, using #atPath: and #atPath:put: + +The first is special because it returns nil as soon as a key is missing. The second is special because it creates extra levels (instances of me) as needed to follow the path of keys. + + NeoJSONObject new atPath: #(one two three) put: 42; yourself. + NeoJSONObject new atPath: #(one two three) put: 42; atPath: #(one two three). + +I am an Dictionary. The official JSON specification clearly states ""An object is an unordered set of name/value pairs"". +I work together with NeoJSONArray. +" +Class { + #name : #NeoJSONObject, + #superclass : #Dictionary, + #category : #'Neo-JSON-Core' +} + +{ #category : #example } +NeoJSONObject class >> exampleCoordinates [ + + ^ (0 to: 4) + collect: [ :each | self new x: each; y: each * 2 ] + as: NeoJSONArray +] + +{ #category : #example } +NeoJSONObject class >> exampleCoordinatesParsing [ + + | result | + result := self fromString: NeoJSONReader exampleCoordinatesJSON. + self assert: result equals: self exampleCoordinates. + ^ result +] + +{ #category : #example } +NeoJSONObject class >> exampleCoordinatesWriting [ + + ^ self exampleCoordinates printString +] + +{ #category : #example } +NeoJSONObject class >> exampleMagnitudeClassHierarchy [ + + | builder | + builder := [ :aClass | + NeoJSONObject new + name: aClass name; + superclass: aClass superclass name; + instanceVariables: aClass instVarNames; + category: aClass category; + totalInstanceVariablesCount: aClass allInstVarNames size; + methodCount: aClass methods size; + totalMethodCount: aClass allMethods size; + subclasses: (aClass subclasses + collect: [ :aSubclass | builder value: aSubclass ] + as: NeoJSONArray) ]. + ^ builder value: Magnitude +] + +{ #category : #example } +NeoJSONObject class >> exampleNested [ + + ^ self exampleSimple array: NeoJSONArray exampleSimple +] + +{ #category : #example } +NeoJSONObject class >> exampleNestedRoundtrip [ + + | json result| + json := self exampleNested printString. + result := self fromString: json. + self assert: result equals: self exampleNested. + ^ result +] + +{ #category : #example } +NeoJSONObject class >> exampleSimple [ + + ^ self new + foo: 100; + bar: 200 +] + +{ #category : #example } +NeoJSONObject class >> exampleSimpleJSON [ + + ^ '{"foo":100,"bar":200}' +] + +{ #category : #example } +NeoJSONObject class >> exampleSimpleParsing [ + + | result | + result := self fromString: self exampleSimpleJSON. + self assert: result equals: self exampleSimple. + ^ result +] + +{ #category : #example } +NeoJSONObject class >> exampleSimpleUsage [ + + | simple | + simple := NeoJSONObject exampleSimple. + self assert: simple foo equals: (simple at: #foo). + self assert: (simple foo: -1) equals: (simple at: #foo put: -1; yourself). + self assert: (simple includesKey: #baz) not. + self assert: simple baz equals: nil. + ^ simple +] + +{ #category : #example } +NeoJSONObject class >> exampleSimpleWriting [ + + | result | + result := self exampleSimple printString. + self assert: result equals: self exampleSimpleJSON. + ^ result +] + +{ #category : #convenience } +NeoJSONObject class >> fromStream: readStream [ + "Parse stream as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ (NeoJSONReader on: readStream readStream) + mapClass: self; + listClass: NeoJSONArray; + propertyNamesAsSymbols: true; + next +] + +{ #category : #convenience } +NeoJSONObject class >> fromString: string [ + "Parse string as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ self fromStream: string readStream +] + +{ #category : #convenience } +NeoJSONObject class >> readFrom: readStream [ + "Parse stream as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ self fromStream: readStream +] + +{ #category : #accessing } +NeoJSONObject >> at: key [ + "I return nil for missing keys. + My superclass would signal a KeyNotFound." + + ^ self at: key ifAbsent: [ nil ] +] + +{ #category : #add } +NeoJSONObject >> at: key add: object [ + ^ self at: key put: object +] + +{ #category : #'nested dictionaries' } +NeoJSONObject >> at: firstKey at: secondKey [ + "I return nil for missing keys. + My superclass would signal a KeyNotFound." + + ^ self atPath: { firstKey. secondKey } +] + +{ #category : #'nested dictionaries' } +NeoJSONObject >> at: firstKey at: secondKey put: value [ + "Store value under secondKey in nested object under firstKey, create new level when needed" + + ^ self atPath: { firstKey. secondKey } put: value +] + +{ #category : #accessing } +NeoJSONObject >> at: key ifPresent: aPresentBlock ifAbsentPut: anAbsentBlock [ + "Lookup the given key in the receiver. If it is present, answer the + value of evaluating the first block optionally with the value associated with the key. + Otherwise store and return the result of evaluating the second block as the new value of the key." + + "Overwritten to patch a bug in the superclass implementation in Pharo 7 and 8. + This problem was fixed in Pharo 9 where this overwrite is no longer necessary but harmless." + + ^ self + at: key + ifPresent: aPresentBlock + ifAbsent: [ self at: key put: anAbsentBlock value ] +] + +{ #category : #accessing } +NeoJSONObject >> atPath: keyCollection [ + "Use each key in keyCollection recursively, return nil when a key is missing. + Note how keys can also be indexes to arrays." + + | value | + value := self. + keyCollection do: [ :each | + value := value at: each ifAbsent: [ ^ nil ] ]. + ^ value +] + +{ #category : #accessing } +NeoJSONObject >> atPath: keyCollection add: newValue [ + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays. + This variant will insert/add to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each add: target species new ] ]. + ^ target at: keyCollection last add: newValue +] + +{ #category : #accessing } +NeoJSONObject >> atPath: keyCollection put: newValue [ + "Use each key in keyCollection recursively, create new levels when needed. + Note how keys can also be indexes to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target + at: each + ifAbsent: [ target at: each put: target species new ] ]. + ^ target at: keyCollection last put: newValue +] + +{ #category : #'reflective operations' } +NeoJSONObject >> doesNotUnderstand: message [ + "Overwritten so that 'self foo' becomes 'self at: #foo' + and 'self foo: 1' becomes 'self at: #foo put: 1' except that self is returned" + + | key | + key := message selector. + key isUnary + ifTrue: [ ^ self at: key ]. + ^ (key isKeyword and: [ key numArgs = 1 ]) + ifTrue: [ self at: key allButLast asSymbol put: message arguments first; yourself ] + ifFalse: [ super doesNotUnderstand: message ] +] + +{ #category : #accessing } +NeoJSONObject >> findPath: conditionBlock [ + "Find and return the first path to an object in the graph that I represent + for which conditionBlock holds. Return nil when not found." + + (conditionBlock value: self) ifTrue: [ ^ #(()) ]. + self keysAndValuesDo: [ :key :value | + (conditionBlock value: value) ifTrue: [ ^ { key } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPath: conditionBlock) ifNotNil: [ :subPath | + ^ { key } , subPath ] ] ]. + ^ nil +] + +{ #category : #accessing } +NeoJSONObject >> findPaths: conditionBlock [ + "Find and return all paths to objects in the graph that I represent + for which conditionBlock holds. Return an empty collection when none are found." + + | found | + found := OrderedCollection new. + self keysAndValuesDo: [ :key :value | + (conditionBlock value: value) ifTrue: [ found add: { key } ]. + (value isCollection and: [ value isString not ]) ifTrue: [ + (value findPaths: conditionBlock) do: [ :subPath | + found add: { key } , subPath ] ] ]. + ^ found +] + +{ #category : #accessing } +NeoJSONObject >> name [ + "Overwritten to make this accessor available as key" + + ^ self at: #name +] + +{ #category : #printing } +NeoJSONObject >> printOn: stream [ + "I use my JSON representation when printing myself" + + [ (NeoJSONWriter on: stream) nextPut: self ] + on: Error + do: [ :exception | + stream + nextPutAll: ' Error printing JSON: '; + print: exception ] +] + +{ #category : #accessing } +NeoJSONObject >> removeAtPath: keyCollection [ + "Use each key in keyCollection recursively and remove the final key. + Note how keys can also be indexes to arrays." + + | target | + keyCollection ifEmpty: [ ^ self ]. + target := self. + keyCollection allButLast do: [ :each | + target := target at: each ifAbsent: [ ^ self ] ]. + ^ target removeKey: keyCollection last +] + +{ #category : #evaluating } +NeoJSONObject >> value [ + "Overwritten to make this accessor available as key" + + ^ self at: #value +] diff --git a/repository/Neo-JSON-Core/NeoJSONObjectMapping.class.st b/repository/Neo-JSON-Core/NeoJSONObjectMapping.class.st new file mode 100644 index 0000000..4217682 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONObjectMapping.class.st @@ -0,0 +1,154 @@ +" +I am NeoJSONObjectMapping. +I describe how instances of a Smalltalk class are mapped to a JSON map. + +I do this using set of NeoJSONPropertyMappings. + +I know the Smalltalk class that I am a mapping for. This class is the schema identifier and is used to instanciate new objects. + +A mapping can be based on any combination of instance variables or accessors (getter/setter pairs). + +I offer a builder interface to constuct property mappings. +" +Class { + #name : #NeoJSONObjectMapping, + #superclass : #NeoJSONMapping, + #instVars : [ + 'subjectClass', + 'properties', + 'allowNil' + ], + #category : 'Neo-JSON-Core' +} + +{ #category : #'initialize-release' } +NeoJSONObjectMapping >> allowNil [ + "Set that I will allow nil/null values when I read/expect an object" + + allowNil := true +] + +{ #category : #accessing } +NeoJSONObjectMapping >> identifier [ + ^ subjectClass +] + +{ #category : #'initialize-release' } +NeoJSONObjectMapping >> initialize [ + super initialize. + properties := OrderedCollection new. + allowNil := false +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapAccessor: accessor [ + ^ self mapAccessor: accessor to: accessor +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapAccessor: accessor mutator: mutator to: propertyName [ + ^ self + mapProperty: propertyName + getter: [ :object | object perform: accessor ] + setter: [ :object :value | object perform: mutator with: value ] +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapAccessor: accessor to: propertyName [ + ^ self + mapProperty: propertyName + getter: [ :object | object perform: accessor ] + setter: [ :object :value | object perform: accessor asMutator with: value ] +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapAccessors: accessors [ + ^ accessors collect: [ :each | self mapAccessor: each ] +] + +{ #category : #convenience } +NeoJSONObjectMapping >> mapAllInstVars [ + ^ self mapInstVars: subjectClass allInstVarNames +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapInstVar: instVarName [ + ^ self mapInstVar: instVarName to: instVarName +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapInstVar: instVarName to: propertyName [ + | index | + index := + "For portability reasons, do not use instVarIndexFor:ifAbsent: + (it doesn't exist in all Smalltalk dialects) but the below approach. + Also, convert to symbols for portability reasons" + (subjectClass allInstVarNames collect: [ :each | each asSymbol ]) + indexOf: instVarName asSymbol + ifAbsent: [ self error: 'Inst var not found: ', instVarName printString ]. + ^ self + mapProperty: propertyName asString + getter: [ :object | object instVarAt: index ] + setter: [ :object :value | object instVarAt: index put: value ] + + +] + +{ #category : #convenience } +NeoJSONObjectMapping >> mapInstVars [ + ^ self mapInstVars: subjectClass instVarNames +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapInstVars: instVarNames [ + ^ instVarNames collect: [ :each | self mapInstVar: each ] +] + +{ #category : #mapping } +NeoJSONObjectMapping >> mapProperty: propertyName getter: readBlock setter: writeBlock [ + | propertyMapping | + propertyMapping := NeoJSONPropertyMapping new. + propertyMapping + propertyName: propertyName; + getter: readBlock; + setter: writeBlock. + properties removeAllSuchThat: [ :each | each propertyName = propertyMapping propertyName ]. + properties addLast: propertyMapping. + ^ propertyMapping +] + +{ #category : #accessing } +NeoJSONObjectMapping >> propertyNamed: propertyName ifAbsent: block [ + | symbolPropertyName | + symbolPropertyName := propertyName asSymbol. + ^ properties detect: [ :each | each propertyName = symbolPropertyName ] ifNone: block +] + +{ #category : #parsing } +NeoJSONObjectMapping >> readFrom: jsonReader [ + | anObject | + anObject := subjectClass new. + allowNil ifTrue: [ + jsonReader parseConstantDo: [ :value | + ^ value ifNotNil: [ jsonReader error: 'Unexpected boolean constant' ] ] ]. + jsonReader parseMapKeysDo: [ :key | + (self propertyNamed: key ifAbsent: [ nil ]) + ifNil: [ + "read, skip & ignore value" + jsonReader next ] + ifNotNil: [ :mapping | + mapping readObject: anObject from: jsonReader ] ]. + ^ anObject +] + +{ #category : #accessing } +NeoJSONObjectMapping >> subjectClass: smalltalkClass [ + subjectClass := smalltalkClass +] + +{ #category : #writing } +NeoJSONObjectMapping >> writeObject: anObject on: jsonWriter [ + jsonWriter writeMapStreamingDo: [ :jsonMapWriter | + properties do: [ :each | + each writeObject: anObject on: jsonMapWriter ] ] +] diff --git a/repository/Neo-JSON-Core/NeoJSONParseError.class.st b/repository/Neo-JSON-Core/NeoJSONParseError.class.st new file mode 100644 index 0000000..7ac00ab --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONParseError.class.st @@ -0,0 +1,11 @@ +" +I am NeoJSONParseError. +I am an Error. + +I am signalled when JSON input is not valid while parsing. +" +Class { + #name : #NeoJSONParseError, + #superclass : #Error, + #category : 'Neo-JSON-Core' +} diff --git a/repository/Neo-JSON-Core/NeoJSONPropertyMapping.class.st b/repository/Neo-JSON-Core/NeoJSONPropertyMapping.class.st new file mode 100644 index 0000000..67a9951 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONPropertyMapping.class.st @@ -0,0 +1,66 @@ +" +I am NeoJSONPropertyMapping. +I describe how a property of a Smalltalk class maps to a JSON property. + +A property is either an instance variable or getter/setter pair. +I hold a getter and setter block to do the actual work. The property name is used in JSON. + +Optionally, the schema for the value of my property can be specified. This is then used recursively. +" +Class { + #name : #NeoJSONPropertyMapping, + #superclass : #Object, + #instVars : [ + 'propertyName', + 'valueSchema', + 'getter', + 'setter' + ], + #category : 'Neo-JSON-Core' +} + +{ #category : #accessing } +NeoJSONPropertyMapping >> getter: block [ + getter := block +] + +{ #category : #printing } +NeoJSONPropertyMapping >> printOn: stream [ + super printOn: stream. + stream nextPut: $(; print: propertyName; nextPut: $) +] + +{ #category : #accessing } +NeoJSONPropertyMapping >> propertyName [ + ^ propertyName +] + +{ #category : #accessing } +NeoJSONPropertyMapping >> propertyName: symbolOrString [ + propertyName := symbolOrString asSymbol +] + +{ #category : #parsing } +NeoJSONPropertyMapping >> readObject: anObject from: jsonReader [ + | value | + value := jsonReader nextAs: valueSchema. + setter value: anObject value: value +] + +{ #category : #accessing } +NeoJSONPropertyMapping >> setter: block [ + setter := block +] + +{ #category : #accessing } +NeoJSONPropertyMapping >> valueSchema: schemaName [ + valueSchema := schemaName +] + +{ #category : #writing } +NeoJSONPropertyMapping >> writeObject: anObject on: jsonMapWriter [ + | value | + value := getter value: anObject. + (value notNil or: [ jsonMapWriter writeNil ]) + ifTrue: [ jsonMapWriter writeKey: propertyName value: value as: valueSchema ] +] diff --git a/repository/Neo-JSON-Core/NeoJSONReader.class.st b/repository/Neo-JSON-Core/NeoJSONReader.class.st new file mode 100644 index 0000000..a203934 --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONReader.class.st @@ -0,0 +1,527 @@ +" +I am NeoJSONReader. +I am a NeoJSONMapper. +I parse a JSON representation from a textual stream into Smalltalk objects. + +Primitive types are automatically mapped to their Smalltalk counterpart: Numbers, Strings, Booleans and UndefinedObject. +When parsing using #next, lists normally become Arrays and maps become Dictionaries. +An alternative listClass or mapClass can be specified. + +When parsing using #nextAs: a schema can be specified. This schema defines a mapping to be used. + +Here are some examples: + + NeoJSONReader fromString: ' [ 1,2,3 ] '. + NeoJSONReader fromString: ' [ 3.14159, true, false, null, ""string"" ] '. + NeoJSONReader fromString: ' { ""x"" : 1, ""y"" : 2 } '. + + (NeoJSONReader on: ' { ""x"" : 1, ""y"" : 2 } ' readStream) + mapInstVarsFor: Point; + nextAs: Point. + + (NeoJSONReader on: '[ { ""x"" : 1, ""y"" : 2 }, { ""x"" : 3, ""y"" : 4 } ]' readStream) + mapInstVarsFor: Point; + for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]; + nextAs: #ArrayOfPoints. + + (NeoJSONReader on: '[ { ""x"" : 1, ""y"" : 2 }, { ""x"" : 3, ""y"" : 4 } ]' readStream) + mapInstVarsFor: Point; + nextListAs: Point. +" +Class { + #name : #NeoJSONReader, + #superclass : #NeoJSONMapper, + #instVars : [ + 'readStream', + 'stringStream', + 'listClass', + 'mapClass', + 'propertyNamesAsSymbols' + ], + #category : #'Neo-JSON-Core' +} + +{ #category : #example } +NeoJSONReader class >> exampleCoordinatesCustomParsing [ + + | reader | + reader := self on: self exampleCoordinatesJSON readStream. + reader mapAllInstVarsFor: Point. + reader for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]. + ^ reader nextAs: #ArrayOfPoints +] + +{ #category : #example } +NeoJSONReader class >> exampleCoordinatesGenericParsing [ + + ^ self fromString: self exampleCoordinatesJSON +] + +{ #category : #example } +NeoJSONReader class >> exampleCoordinatesJSON [ + + ^ '[{"x":0,"y":0},{"x":1,"y":2},{"x":2,"y":4},{"x":3,"y":6},{"x":4,"y":8}]' +] + +{ #category : #convenience } +NeoJSONReader class >> fromString: string [ + ^ (self on: string readStream) next +] + +{ #category : #convenience } +NeoJSONReader class >> fromString: string as: schema [ + ^ (self on: string readStream) nextAs: schema +] + +{ #category : #'instance creation' } +NeoJSONReader class >> on: readStream [ + "Initialize on readStream, which should be a character stream that + implements #next, #peek, #atEnd and (optionally) #close." + + ^ self new + on: readStream; + yourself +] + +{ #category : #testing } +NeoJSONReader >> atEnd [ + ^ readStream atEnd +] + +{ #category : #'initialize-release' } +NeoJSONReader >> close [ + readStream ifNotNil: [ + readStream close. + readStream := nil ] +] + +{ #category : #private } +NeoJSONReader >> consumeWhitespace [ + "Strip whitespaces from the input stream." + + [ readStream atEnd not and: [ readStream peek isSeparator ] ] + whileTrue: [ + readStream next ] +] + +{ #category : #private } +NeoJSONReader >> error: text [ + NeoJSONParseError signal: text +] + +{ #category : #private } +NeoJSONReader >> expectChar: character [ + "Expect character and consume input and optional whitespace at the end, + throw an error otherwise." + + (self matchChar: character) + ifFalse: [ self error: character asString, ' expected' ] +] + +{ #category : #parsing } +NeoJSONReader >> failIfNotAtEnd [ + self atEnd + ifFalse: [ self error: 'extraneous input detected' ] +] + +{ #category : #'initialize-release' } +NeoJSONReader >> initialize [ + super initialize. + propertyNamesAsSymbols := false +] + +{ #category : #accessing } +NeoJSONReader >> listClass [ + "Return the collection type to use for JSON lists" + + ^ listClass ifNil: [ Array ] +] + +{ #category : #'initialize-release' } +NeoJSONReader >> listClass: collectionClass [ + listClass := collectionClass +] + +{ #category : #accessing } +NeoJSONReader >> mapClass [ + "Return the collection type to use for JSON maps" + + ^ mapClass ifNil: [ Dictionary ] +] + +{ #category : #'initialize-release' } +NeoJSONReader >> mapClass: collectionClass [ + mapClass := collectionClass +] + +{ #category : #private } +NeoJSONReader >> match: string do: block [ + "Try to read and consume string and execute block if successful. + Else do nothing (but do not back up)" + + (string allSatisfy: [ :each | readStream peekFor: each ]) + ifTrue: [ + self consumeWhitespace. + block value ] +] + +{ #category : #private } +NeoJSONReader >> matchChar: character [ + "Tries to match character, consume input and + answer true if successful and consumes whitespace at the end. + When character does not match, return false and leave stream untouched." + + ^ (readStream peekFor: character) + ifTrue: [ + self consumeWhitespace. + true ] + ifFalse: [ false ] +] + +{ #category : #accessing } +NeoJSONReader >> next [ + "Primary interface to parse a JSON value. + Return either primitives, a listClass or a mapClass instance." + + ^ self + consumeWhitespace; + parseValue +] + +{ #category : #accessing } +NeoJSONReader >> nextAs: schema [ + "Secondary interface to parse JSON. + Return an object according to schema. + If schema is nil, act like #next" + + | mapping | + schema ifNil: [ ^ self next ]. + self consumeWhitespace. + mapping := self mappingFor: schema. + ^ mapping readFrom: self +] + +{ #category : #accessing } +NeoJSONReader >> nextListAs: schema [ + "Secondary interface to parse JSON. + Return a list of objects, each element according to schema." + + ^ self listClass streamContents: [ :stream | + self parseListDo: [ + stream nextPut: (self nextAs: schema) ] ] +] + +{ #category : #'initialize-release' } +NeoJSONReader >> on: aReadStream [ + "Initialize on aReadStream, which should be a character stream that + implements #next, #peek, #atEnd and (optionally) #close." + + readStream := aReadStream +] + +{ #category : #parsing } +NeoJSONReader >> parseCharacter [ + | char | + (char := readStream next) = $\ + ifFalse: [ ^ char ]. + ('/"\' includes: (char := readStream next)) + ifTrue: [ ^ char ]. + ('bfnrt' includes: char) + ifTrue: [ ^ self unescapeChar: char ]. + char = $u + ifTrue: [ ^ self parseCharacterHex ]. + char + ifNil: [ self error: 'invalid escape, end of file' ] + ifNotNil: [ self error: 'invalid escape character \' , char asString ] +] + +{ #category : #private } +NeoJSONReader >> parseCharacterHex [ + | value codePoint | + value := self parseCharacterHex4Value. + (value < 16rD800 or: [ value > 16rDBFF ]) + ifTrue: [ codePoint := value ] + ifFalse: [ | leadSurrogate trailSurrogate | + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + "See https://tools.ietf.org/html/rfc7159#section-7" + leadSurrogate := value. + trailSurrogate := self parseTrailingSurrogateHexEscape. + codePoint := (leadSurrogate - 16rD800) * 16r400 + (trailSurrogate - 16rDC00). + codePoint := 16r10000 + codePoint. + codePoint > 16r10FFFF + ifTrue: [ self error: 'Character Unicode code point outside encoder range' ] ]. + ^ Character codePoint: codePoint +] + +{ #category : #private } +NeoJSONReader >> parseCharacterHex4Value [ + | value | + value := self parseCharacterHexDigit. + 3 timesRepeat: [ + value := (value << 4) + self parseCharacterHexDigit ]. + ^ value +] + +{ #category : #private } +NeoJSONReader >> parseCharacterHexDigit [ + | digit | + readStream atEnd + ifFalse: [ + digit := readStream next asInteger. + (digit between: "$0" 48 and: "$9" 57) + ifTrue: [ ^ digit - 48 ]. + (digit between: "$A" 65 and: "$F" 70) + ifTrue: [ ^ digit - 55 ]. + (digit between: "$a" 97 and: "$f" 102) + ifTrue: [ ^ digit - 87 ] ]. + self error: 'hex-digit expected' +] + +{ #category : #private } +NeoJSONReader >> parseConstantDo: block [ + "Parse and consume either true|false|nil|null and execute block + or else do nothing (but do not back up). + Hand written implementation to avoid the use of #position:" + + (readStream peek = $t) + ifTrue: [ + ^ self match: 'true' do: [ block value: true ] ]. + (readStream peek = $f) + ifTrue: [ + ^ self match: 'false' do: [ block value: false ] ]. + (readStream peek = $n) + ifTrue: [ + ^ self match: 'null' do: [ block value: nil ] ] + +] + +{ #category : #parsing } +NeoJSONReader >> parseList [ + ^ self listClass + streamContents: [ :stream | + self parseListElementsDo: [ :each | + stream nextPut: each ] ] + + +] + +{ #category : #parsing } +NeoJSONReader >> parseListDo: block [ + self expectChar: $[. + (self matchChar: $]) + ifTrue: [ ^ self ]. + [ readStream atEnd ] + whileFalse: [ + block value. + (self matchChar: $]) + ifTrue: [ ^ self ]. + (self matchChar: $,) + ifFalse: [ self error: ', or ] expected' ] ]. + self error: 'incomplete list' +] + +{ #category : #parsing } +NeoJSONReader >> parseListElementsDo: block [ + self parseListDo: [ + block value: self parseValue ] +] + +{ #category : #parsing } +NeoJSONReader >> parseMap [ + | map | + map := self mapClass new. + self parseMapKeysAndValuesDo: [ :key :value | + map at: key put: value ]. + ^ map +] + +{ #category : #parsing } +NeoJSONReader >> parseMapDo: block [ + self expectChar: ${. + (self matchChar: $}) + ifTrue: [ ^ self ]. + [ readStream atEnd ] whileFalse: [ + block value. + (self matchChar: $}) + ifTrue: [ ^ self ]. + (self matchChar: $,) + ifFalse: [ self error: ', or } expected' ] ]. + self error: 'incomplete map' +] + +{ #category : #parsing } +NeoJSONReader >> parseMapKeysAndValuesDo: block [ + self parseMapKeysDo: [ :key | + block value: key value: self parseValue ] +] + +{ #category : #parsing } +NeoJSONReader >> parseMapKeysDo: block [ + self parseMapDo: [ | key | + key := self parsePropertyName. + self expectChar: $:. + block value: key ] +] + +{ #category : #parsing } +NeoJSONReader >> parseNumber [ + | negated number isFloat | + negated := readStream peekFor: $-. + number := self parseNumberInteger. + isFloat := (readStream peekFor: $.) + ifTrue: [ number := number + self parseNumberFraction. true ] + ifFalse: [ false ]. + ((readStream peekFor: $e) or: [ readStream peekFor: $E ]) + ifTrue: [ number := number * self parseNumberExponent ]. + isFloat ifTrue: [ number := number asFloat ]. + negated + ifTrue: [ number := number negated ]. + self consumeWhitespace. + ^ number +] + +{ #category : #parsing } +NeoJSONReader >> parseNumberExponent [ + | number negated | + number := 0. + (negated := readStream peekFor: $-) + ifFalse: [ readStream peekFor: $+ ]. + (readStream atEnd or: [ readStream peek isDigit not ]) + ifTrue: [ self error: 'number exponent expected' ]. + [ readStream atEnd not and: [ readStream peek isDigit ] ] + whileTrue: [ number := 10 * number + readStream next digitValue ]. + negated + ifTrue: [ number := number negated ]. + number positive + ifTrue: [ number > Float emax ifTrue: [ self error: 'number exponent too large' ] ] + ifFalse: [ number < Float emin ifTrue: [ self error: 'number exponent too small' ] ]. + ^ 10 raisedTo: number +] + +{ #category : #parsing } +NeoJSONReader >> parseNumberFraction [ + | number power | + number := 0. + power := 1. + [ readStream atEnd not and: [ readStream peek isDigit ] ] + whileTrue: [ + number := 10 * number + readStream next digitValue. + power := power * 10 ]. + ^ number / power +] + +{ #category : #parsing } +NeoJSONReader >> parseNumberInteger [ + | number | + number := nil. + [ readStream atEnd not and: [ readStream peek isDigit ] ] + whileTrue: [ + number := 10 * (number ifNil: [ 0 ]) + readStream next digitValue ]. + number ifNil: [ self error: 'Integer digit expected' ]. + ^ number +] + +{ #category : #parsing } +NeoJSONReader >> parsePropertyName [ + | name | + name := self parseValue. + ^ name isString + ifTrue: [ + propertyNamesAsSymbols + ifTrue: [ name asSymbol ] + ifFalse: [ name ] ] + ifFalse: [ + self error: 'property name must be a string, not ', name asString ] +] + +{ #category : #parsing } +NeoJSONReader >> parseString [ + | result | + (readStream peekFor: $") + ifFalse: [ self error: '" expected' ]. + result := self stringStreamContents: [ :stream | + [ readStream atEnd or: [ readStream peek = $" ] ] + whileFalse: [ stream nextPut: self parseCharacter ] ]. + self expectChar: $". + ^ result +] + +{ #category : #private } +NeoJSONReader >> parseTrailingSurrogateHexEscape [ + (readStream next = $\ and: [ readStream next = $u ]) + ifTrue: [ ^ self parseCharacterHex4Value ] + ifFalse: [ self error: 'trailing surrogate hex escape expected' ] +] + +{ #category : #parsing } +NeoJSONReader >> parseValue [ + | char | + readStream atEnd ifFalse: [ + char := readStream peek. + char = ${ + ifTrue: [ ^ self parseMap ]. + char = $[ + ifTrue: [ ^ self parseList ]. + char = $" + ifTrue: [ ^ self parseString ]. + (char = $- or: [ char isDigit ]) + ifTrue: [ ^ self parseNumber ]. + self parseConstantDo: [ :value | ^ value ] ]. + self error: 'invalid input: ', char asString +] + +{ #category : #'initialize-release' } +NeoJSONReader >> propertyNamesAsSymbols: boolean [ + propertyNamesAsSymbols := boolean +] + +{ #category : #private } +NeoJSONReader >> stringStreamClass [ + "Answer the class of the collection used for the stringStream of receiver. + + NOTE: It is String, but if receiver's readStream is over + another class of String, then this provides compatibility for that." + + ^ readStream collectionSpecies +] + +{ #category : #private } +NeoJSONReader >> stringStreamContents: block [ + "Like String streamContents: block + but reusing the underlying buffer for improved efficiency" + + stringStream ifNil: [ + stringStream := (self stringStreamClass new: 32) writeStream ]. + stringStream reset. + block value: stringStream. + ^ stringStream contents +] + +{ #category : #private } +NeoJSONReader >> unescapeChar: char [ + "Handle one of the named character escapes, b, f, n, r or t. Else fail." + + char = $b + ifTrue: [ ^ Character backspace ]. + char = $f + ifTrue: [ ^ Character newPage ]. + char = $n + ifTrue: [ ^ Character lf ]. + char = $r + ifTrue: [ ^ Character cr ]. + char = $t + ifTrue: [ ^ Character tab ]. + self error: 'Unknown escape char: ', (String with: char) +] + +{ #category : #accessing } +NeoJSONReader >> upToEnd [ + "Parse and collect JSON values from my stream until it ends, returning the collection. + This supports Newline delimited JSON (application/x-ndjson) & JSON Lines (application/jsonl). + Warning: though each element is valid JSON, taken as a whole the result is non-valid JSON." + + ^ Array streamContents: [ :out | + [ self atEnd ] whileFalse: [ out nextPut: self next ] ] +] diff --git a/repository/Neo-JSON-Core/NeoJSONStreamingWriter.class.st b/repository/Neo-JSON-Core/NeoJSONStreamingWriter.class.st new file mode 100644 index 0000000..f2c885e --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONStreamingWriter.class.st @@ -0,0 +1,87 @@ +" +I am NeoJSONStreamingWriter. +I help in writing streamed maps and lists. + +This is an internal class used by NeoJSONWriter to deal with interleaving elements and separators as well as pretty printing. +" +Class { + #name : #NeoJSONStreamingWriter, + #superclass : #Object, + #instVars : [ + 'jsonWriter', + 'first' + ], + #category : 'Neo-JSON-Core' +} + +{ #category : #'instance creation' } +NeoJSONStreamingWriter class >> on: jsonWriter [ + ^ self new + on: jsonWriter; + yourself +] + +{ #category : #'initialize-release' } +NeoJSONStreamingWriter >> initialize [ + super initialize. + first := true +] + +{ #category : #'initialize-release' } +NeoJSONStreamingWriter >> on: aJSONWriter [ + jsonWriter := aJSONWriter +] + +{ #category : #testing } +NeoJSONStreamingWriter >> wasUsed [ + ^ first not +] + +{ #category : #writing } +NeoJSONStreamingWriter >> writeElement: value [ + first + ifTrue: [ + jsonWriter newlineIndent. + first := false ] + ifFalse: [ + jsonWriter listElementSeparator ]. + jsonWriter nextPut: value +] + +{ #category : #writing } +NeoJSONStreamingWriter >> writeElement: value as: valueSchema [ + first + ifTrue: [ + jsonWriter newlineIndent. + first := false ] + ifFalse: [ + jsonWriter listElementSeparator ]. + jsonWriter nextPut: value as: valueSchema +] + +{ #category : #writing } +NeoJSONStreamingWriter >> writeKey: key value: value [ + first + ifTrue: [ + jsonWriter newlineIndent. + first := false ] + ifFalse: [ + jsonWriter mapElementSeparator ]. + jsonWriter encodeKey: key value: value +] + +{ #category : #writing } +NeoJSONStreamingWriter >> writeKey: key value: value as: valueSchema [ + first + ifTrue: [ + jsonWriter newlineIndent. + first := false ] + ifFalse: [ + jsonWriter mapElementSeparator ]. + jsonWriter encodeKey: key value: value as: valueSchema +] + +{ #category : #accessing } +NeoJSONStreamingWriter >> writeNil [ + ^ jsonWriter writeNil +] diff --git a/repository/Neo-JSON-Core/NeoJSONWriter.class.st b/repository/Neo-JSON-Core/NeoJSONWriter.class.st new file mode 100644 index 0000000..ba3fb1d --- /dev/null +++ b/repository/Neo-JSON-Core/NeoJSONWriter.class.st @@ -0,0 +1,399 @@ +" +I am NeoJSONWriter. +I am a NeoJSONMapper. +I write a JSON representation of Smalltalk objects to a textual stream. + +Objects implementing #neoJsonOn: can be encoded. +A number of primitive types, like Strings, Numbers, Booleans and UndefinedObject are treated specially. +Collection are encoded as lists, except for Dictionaries that are encoded as maps. + +All other objects need a mapping to help in doing the encoding. + +Here are some examples: + + NeoJSONWriter toString: #(1 2 3). + NeoJSONWriter toString: { Float pi. true. false. 'string' }. + NeoJSONWriter toStringPretty: (Dictionary new at: #x put: 1; at: #y put: 2; yourself). + + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + prettyPrint: true; + mapInstVarsFor: Point; + nextPut: (Array with: 1@3 with: -1@3) ]. + +" +Class { + #name : #NeoJSONWriter, + #superclass : #NeoJSONMapper, + #instVars : [ + 'writeStream', + 'prettyPrint', + 'level', + 'newLine', + 'asciiOnly', + 'writeNil', + 'floatPrinter' + ], + #category : #'Neo-JSON-Core' +} + +{ #category : #example } +NeoJSONWriter class >> exampleCoordinates [ + + ^ { 0@0 . 1@2. 2@4. 3@6 . 4@8} +] + +{ #category : #example } +NeoJSONWriter class >> exampleCoordinatesCustomWriting [ + + ^ String streamContents: [ :out | + | writer | + writer := self on: out. + writer mapAllInstVarsFor: Point. + writer nextPut: self exampleCoordinates ] +] + +{ #category : #example } +NeoJSONWriter class >> exampleCoordinatesGeneric [ + + ^ (0 to: 4) collect: [ :each | { 'x' -> each . 'y' -> (each * 2) } asDictionary ] +] + +{ #category : #example } +NeoJSONWriter class >> exampleCoordinatesGenericWriting [ + + ^ self toString: self exampleCoordinatesGeneric +] + +{ #category : #'instance creation' } +NeoJSONWriter class >> on: writeStream [ + "Initialize on writeStream, which should be a character stream that + implements #nextPut:, #nextPutAll:, #space and (optionally) #close." + + ^ self new + on: writeStream; + yourself +] + +{ #category : #convenience } +NeoJSONWriter class >> toString: object [ + ^ String streamContents: [ :stream | + (self on: stream) nextPut: object ] +] + +{ #category : #convenience } +NeoJSONWriter class >> toStringPretty: object [ + ^ String streamContents: [ :stream | + (self on: stream) + prettyPrint: true; + nextPut: object ] +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> asciiOnly: boolean [ + "Set whether I should escape all non ASCII characters or not" + + asciiOnly := boolean +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> close [ + "Close the stream that I write to" + + writeStream ifNotNil: [ + writeStream close. + writeStream := nil ] +] + +{ #category : #private } +NeoJSONWriter >> doesCodePointNeedEscaping: code [ + code < 32 ifTrue: [ ^ true ]. + ( code = 34 or: [ code = 92 ]) ifTrue: [ ^ true ]. + ^ asciiOnly and: [ code > 126 ] +] + +{ #category : #private } +NeoJSONWriter >> encodeChar: char [ + | code | + code := char codePoint. + (self doesCodePointNeedEscaping: code) + ifTrue: [ self escapeChar: code ] + ifFalse: [ writeStream nextPut: char ] +] + +{ #category : #private } +NeoJSONWriter >> encodeKey: key [ + key isString ifFalse: [ ^ self error: 'JSON key names in objects must be strings' ]. + self nextPut: key. + self prettyPrintSpace. + writeStream nextPut: $:. + self prettyPrintSpace +] + +{ #category : #private } +NeoJSONWriter >> encodeKey: key value: value [ + self encodeKey: key. + self nextPut: value +] + +{ #category : #private } +NeoJSONWriter >> encodeKey: key value: value as: valueSchema [ + self encodeKey: key. + self nextPut: value as: valueSchema +] + +{ #category : #private } +NeoJSONWriter >> escapeChar: code [ + code = 34 + ifTrue: [ ^ writeStream nextPutAll: '\"' ]. + code = 92 + ifTrue: [ ^ writeStream nextPutAll: '\\' ]. + code = 47 + ifTrue: [ ^ writeStream nextPutAll: '\/' ]. + code = 8 + ifTrue: [ ^ writeStream nextPutAll: '\b' ]. + code = 12 + ifTrue: [ ^ writeStream nextPutAll: '\f' ]. + code = 10 + ifTrue: [ ^ writeStream nextPutAll: '\n' ]. + code = 13 + ifTrue: [ ^ writeStream nextPutAll: '\r' ]. + code = 9 + ifTrue: [ ^ writeStream nextPutAll: '\t' ]. + self escapeUnicode: code +] + +{ #category : #private } +NeoJSONWriter >> escapeUnicode4: codePoint [ + writeStream nextPutAll: '\u'. + codePoint printOn: writeStream base: 16 nDigits: 4 +] + +{ #category : #private } +NeoJSONWriter >> escapeUnicode: codePoint [ + codePoint <= 16rFFFF + ifTrue: [ self escapeUnicode4: codePoint ] + ifFalse: [ + codePoint <= 16r10FFFF + ifTrue: [ | leadSurrogate trailSurrogate shifted | + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + "See https://tools.ietf.org/html/rfc7159#section-7" + shifted := codePoint - 16r10000. + leadSurrogate := 16rD800 + (shifted // 16r400). + trailSurrogate := 16rDC00 + (shifted \\ 16r400). + self escapeUnicode4: leadSurrogate. + self escapeUnicode4: trailSurrogate ] + ifFalse: [ self error: 'Character Unicode code point outside encoder range' ] ] +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> floatPrinter: anObject [ + "Set the float print, an object that implements #printFloat:on: + By default, I am my own float printer" + + floatPrinter := anObject +] + +{ #category : #private } +NeoJSONWriter >> indentedDo: block [ + level := level + 1. + block value. + level := level - 1 +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> initialize [ + super initialize. + self newLine: String lf. + self prettyPrint: false. + self asciiOnly: false. + self writeNil: false. + self floatPrinter: self. + level := 0 +] + +{ #category : #private } +NeoJSONWriter >> listElementSeparator [ + writeStream nextPut: $,. + self newlineIndent + +] + +{ #category : #private } +NeoJSONWriter >> mapElementSeparator [ + writeStream nextPut: $,. + self newlineIndent + +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> newLine: string [ + "Set the newline string that I should use when pretty printing" + + newLine := string +] + +{ #category : #accessing } +NeoJSONWriter >> newline [ + "Write a newline on the stream that I wrap. + What gets written depends on the configuration, see #newLine:" + + writeStream nextPutAll: newLine +] + +{ #category : #private } +NeoJSONWriter >> newlineIndent [ + prettyPrint + ifTrue: [ + self newline. + level timesRepeat: [ writeStream nextPut: Character tab ] ] +] + +{ #category : #accessing } +NeoJSONWriter >> nextPut: anObject [ + "Primary interface. Write a JSON representation of anObject to my stream." + + anObject neoJsonOn: self +] + +{ #category : #accessing } +NeoJSONWriter >> nextPut: anObject as: schema [ + "Secondary interface to write JSON. + Write objects according to schema." + + | mapping | + (schema isNil or: [ anObject isNil ]) ifTrue: [ ^ self nextPut: anObject ]. + mapping := self mappingFor: schema. + ^ mapping writeObject: anObject on: self +] + +{ #category : #accessing } +NeoJSONWriter >> nextPutAll: aCollection [ + "Write a separate JSON representation of all objects in aCollection to my stream. + This supports Newline delimited JSON (application/x-ndjson) & JSON Lines (application/jsonl). + Warning: though each element is valid JSON, taken as a whole the result is non-valid JSON." + + aCollection do: [ :each | + self nextPut: each. + self newline ] +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> on: aWriteStream [ + "Initialize on aWriteStream, which should be a character stream that + implements #nextPut:, #nextPutAll:, #space and (optionally) #close." + + writeStream := aWriteStream + +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> prettyPrint: boolean [ + "Set whether I should pretty print the JSON that I write" + + prettyPrint := boolean +] + +{ #category : #private } +NeoJSONWriter >> prettyPrintSpace [ + prettyPrint + ifTrue: [ writeStream nextPut: Character space ] +] + +{ #category : #printing } +NeoJSONWriter >> printFloat: float on: stream [ + "See NeoJSONFloatPrinter for a custom float printer" + + float printOn: stream +] + +{ #category : #writing } +NeoJSONWriter >> writeBoolean: boolean [ + boolean printOn: writeStream +] + +{ #category : #writing } +NeoJSONWriter >> writeFloat: float [ + floatPrinter printFloat: float on: writeStream +] + +{ #category : #writing } +NeoJSONWriter >> writeInteger: integer [ + integer printOn: writeStream + +] + +{ #category : #writing } +NeoJSONWriter >> writeList: collection [ + self writeListStreamingDo: [ :jsonListWriter | + collection do: [ :each | + jsonListWriter writeElement: each ] ] +] + +{ #category : #writing } +NeoJSONWriter >> writeListStreamingDo: block [ + writeStream nextPut: $[. + self writeStreamingDo: block. + writeStream nextPut: $] +] + +{ #category : #writing } +NeoJSONWriter >> writeMap: keyValueCollection [ + self writeMapStreamingDo: [ :jsonMapWriter | + keyValueCollection keysAndValuesDo: [ :key :value | + jsonMapWriter writeKey: key value: value ] ] +] + +{ #category : #writing } +NeoJSONWriter >> writeMapStreamingDo: block [ + writeStream nextPut: ${. + self writeStreamingDo: block. + writeStream nextPut: $} +] + +{ #category : #accessing } +NeoJSONWriter >> writeNil [ + "Return whether I will write nil/null properties of objects or skip them." + + ^ writeNil +] + +{ #category : #'initialize-release' } +NeoJSONWriter >> writeNil: boolean [ + "Set whether I will write nil/null properties of objects or skip them." + + writeNil := boolean +] + +{ #category : #writing } +NeoJSONWriter >> writeNull [ + writeStream nextPutAll: 'null' +] + +{ #category : #writing } +NeoJSONWriter >> writeObject: anObject [ + | mapping | + mapping := self mappingFor: anObject class. + mapping + writeObject: anObject + on: self +] + +{ #category : #writing } +NeoJSONWriter >> writeStreamingDo: block [ + | mapWriter | + mapWriter := NeoJSONStreamingWriter on: self. + self indentedDo: [ + block value: mapWriter ]. + mapWriter wasUsed + ifTrue: [ self newlineIndent ] + ifFalse: [ self prettyPrintSpace ] +] + +{ #category : #writing } +NeoJSONWriter >> writeString: string [ + writeStream nextPut: $". + 1 to: string size do: [ :index | + self encodeChar: (string at: index) ]. + writeStream nextPut: $" +] diff --git a/repository/Neo-JSON-Core/Number.extension.st b/repository/Neo-JSON-Core/Number.extension.st new file mode 100644 index 0000000..773aae7 --- /dev/null +++ b/repository/Neo-JSON-Core/Number.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Number } + +{ #category : #'*neo-json-core' } +Number >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeFloat: self asFloat +] diff --git a/repository/Neo-JSON-Core/Object.extension.st b/repository/Neo-JSON-Core/Object.extension.st new file mode 100644 index 0000000..33b54ae --- /dev/null +++ b/repository/Neo-JSON-Core/Object.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #Object } + +{ #category : #'*neo-json-core' } +Object >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeObject: self +] diff --git a/repository/Neo-JSON-Core/String.extension.st b/repository/Neo-JSON-Core/String.extension.st new file mode 100644 index 0000000..a08484f --- /dev/null +++ b/repository/Neo-JSON-Core/String.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #String } + +{ #category : #'*neo-json-core' } +String >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeString: self +] diff --git a/repository/Neo-JSON-Core/UndefinedObject.extension.st b/repository/Neo-JSON-Core/UndefinedObject.extension.st new file mode 100644 index 0000000..1979e16 --- /dev/null +++ b/repository/Neo-JSON-Core/UndefinedObject.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #UndefinedObject } + +{ #category : #'*neo-json-core' } +UndefinedObject >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeNull +] diff --git a/repository/Neo-JSON-Core/package.st b/repository/Neo-JSON-Core/package.st new file mode 100644 index 0000000..61507be --- /dev/null +++ b/repository/Neo-JSON-Core/package.st @@ -0,0 +1 @@ +Package { #name : #'Neo-JSON-Core' } diff --git a/repository/Neo-JSON-Pharo-Core/OrderedDictionary.extension.st b/repository/Neo-JSON-Pharo-Core/OrderedDictionary.extension.st new file mode 100644 index 0000000..21e6fc6 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Core/OrderedDictionary.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #OrderedDictionary } + +{ #category : #'*neo-json-pharo-core' } +OrderedDictionary >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeMap: self +] diff --git a/repository/Neo-JSON-Pharo-Core/SmallDictionary.extension.st b/repository/Neo-JSON-Pharo-Core/SmallDictionary.extension.st new file mode 100644 index 0000000..6deee60 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Core/SmallDictionary.extension.st @@ -0,0 +1,6 @@ +Extension { #name : #SmallDictionary } + +{ #category : #'*neo-json-pharo-core' } +SmallDictionary >> neoJsonOn: neoJSONWriter [ + neoJSONWriter writeMap: self +] diff --git a/repository/Neo-JSON-Pharo-Core/package.st b/repository/Neo-JSON-Pharo-Core/package.st new file mode 100644 index 0000000..2061d58 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Core/package.st @@ -0,0 +1 @@ +Package { #name : #'Neo-JSON-Pharo-Core' } diff --git a/repository/Neo-JSON-Pharo-Examples/Attachment.class.st b/repository/Neo-JSON-Pharo-Examples/Attachment.class.st new file mode 100644 index 0000000..65b7a2e --- /dev/null +++ b/repository/Neo-JSON-Pharo-Examples/Attachment.class.st @@ -0,0 +1,19 @@ +Class { + #name : #Attachment, + #superclass : #Object, + #instVars : [ + 'url', + 'fileName' + ], + #category : 'Neo-JSON-Pharo-Examples' +} + +{ #category : #accessing } +Attachment >> fileName: anObject [ + fileName := anObject +] + +{ #category : #accessing } +Attachment >> url: anObject [ + url := anObject +] diff --git a/repository/Neo-JSON-Pharo-Examples/BittrexResponse.class.st b/repository/Neo-JSON-Pharo-Examples/BittrexResponse.class.st new file mode 100644 index 0000000..c240636 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Examples/BittrexResponse.class.st @@ -0,0 +1,10 @@ +Class { + #name : #BittrexResponse, + #superclass : #Object, + #instVars : [ + 'success', + 'message', + 'result' + ], + #category : 'Neo-JSON-Pharo-Examples' +} diff --git a/repository/Neo-JSON-Pharo-Examples/Market.class.st b/repository/Neo-JSON-Pharo-Examples/Market.class.st new file mode 100644 index 0000000..b98ac21 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Examples/Market.class.st @@ -0,0 +1,18 @@ +Class { + #name : #Market, + #superclass : #Object, + #instVars : [ + 'MarketCurrency', + 'BaseCurrency', + 'MarketCurrencyLong', + 'BaseCurrencyLong', + 'MinTradeSize', + 'MarketName', + 'IsActive', + 'Created', + 'Notice', + 'IsSponsored', + 'LogoUrl' + ], + #category : 'Neo-JSON-Pharo-Examples' +} diff --git a/repository/Neo-JSON-Pharo-Examples/NeoJSONPharoExamples.class.st b/repository/Neo-JSON-Pharo-Examples/NeoJSONPharoExamples.class.st new file mode 100644 index 0000000..6335019 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Examples/NeoJSONPharoExamples.class.st @@ -0,0 +1,137 @@ +Class { + #name : #NeoJSONPharoExamples, + #superclass : #TestCase, + #category : 'Neo-JSON-Pharo-Examples' +} + +{ #category : #tests } +NeoJSONPharoExamples >> testAccessingTheNewYorkPublicLibrary [ + + | client reader data networkStream | + (client := ZnClient new) + streaming: true; + url: 'https://github.com/NYPL-publicdomain/data-and-utilities/blob/master/items/pd_items_1.ndjson?raw=true'; + get. + networkStream := ZnCharacterReadStream on: client contents. + reader := NeoJSONReader on: networkStream. + data := Array streamContents: [ :out | [ reader atEnd ] whileFalse: [ out nextPut: reader next ] ]. + client close. + data +] + +{ #category : #tests } +NeoJSONPharoExamples >> testAttachmentsExample [ + | collectionOne json | + "Let's create a collection of two instances:" + collectionOne := {(Attachment new + url: 'http://example.com/random-name.txt' asZnUrl; + fileName: 'chapter-one.txt' yourself). + (Attachment new + url: 'http://example.com/random-name.png' asZnUrl; + fileName: 'image.png'; + yourself)}. + + "And let's map it to a JSON structure:" + json := String + streamContents: [ :aStream | + (NeoJSONWriter on: aStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + mapAllInstVarsFor: Attachment; + for: ZnUrl customDo: [ :mapping | mapping encoder: [ :aZnUrl | aZnUrl asString ] ]; + nextPut: collectionOne as: #CollectionOfAttachments ]. + + + "And read the JSON structure:" + (NeoJSONReader on: json readStream) + for: #CollectionOfAttachments customDo: [ :mapping | mapping listOfElementSchema: Attachment ]; + for: Attachment + do: [ :mapping | + mapping mapInstVar: 'fileName'. + (mapping mapInstVar: 'url') valueSchema: ZnUrl ]; + for: ZnUrl customDo: [ :mapping | mapping decoder: [ :string | string asZnUrl ] ]; + nextAs: #CollectionOfAttachments +] + +{ #category : #tests } +NeoJSONPharoExamples >> testBittrexLitecoinAsDictionary [ + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarketSummary?market=BTC-LTC'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader next ]; + get. + +] + +{ #category : #tests } +NeoJSONPharoExamples >> testBittrexLitecoinAsDomainObjects [ + ZnClient new + url: 'https://bittrex.com/api/v1.1/public/getmarkets'; + enforceHttpSuccess: true; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | |reader| + reader := (NeoJSONReader on: entity readStream). + reader for: BittrexResponse do: [:m| + m mapInstVar: #success. + m mapInstVar: #message. + (m mapInstVar: #result) valueSchema: #ArrayOfMarkets]. + reader for: #ArrayOfMarkets customDo: [ :mapping | mapping listOfElementSchema: Market ]. + reader mapInstVarsFor: Market. + reader nextAs: BittrexResponse ]; + get +] + +{ #category : #tests } +NeoJSONPharoExamples >> testDoomtownDBCards [ + + NeoJSONReader fromString: 'http://dtdb.co/api/cards/' asUrl retrieveContents +] + +{ #category : #tests } +NeoJSONPharoExamples >> testFeed [ + | json | + json := ZnClient new + systemPolicy; + url: 'https://daringfireball.net/feeds/json'; + accept: ZnMimeType applicationJson; + contentReader: [ :entity | NeoJSONObject fromString: entity contents ]; + get. + json items collect: #title. + json items collect: [ :each | each title -> each url ]. + json +] + +{ #category : #tests } +NeoJSONPharoExamples >> testGetWorldCapitals [ + ((NeoJSONReader fromString: (ZnEasy get: 'http://api.geonames.org/countryInfoJSON' username: 'demo' password: '') contents) at: #geonames) + collect: [ :d | d at: #capital ] +] + +{ #category : #tests } +NeoJSONPharoExamples >> testGoogleMapsAPI [ + + ZnClient new + url: 'http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get +] + +{ #category : #tests } +NeoJSONPharoExamples >> testParsingUserAgentStrings [ + ZnClient new + http; + host: 'useragentstring.com'; + queryAt: 'uas' put: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/601.4.4 (KHTML, like Gecko) Version/9.0.3 Safari/601.4.4'; + queryAt: 'getJSON' put: 'all'; + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get +] + +{ #category : #tests } +NeoJSONPharoExamples >> testStackOverflowInfo [ + + ZnClient new + contentReader: [ :entity | NeoJSONReader fromString: entity contents ]; + get: 'http://api.stackexchange.com/2.1/info?site=stackoverflow' +] diff --git a/repository/Neo-JSON-Pharo-Examples/package.st b/repository/Neo-JSON-Pharo-Examples/package.st new file mode 100644 index 0000000..c375c4c --- /dev/null +++ b/repository/Neo-JSON-Pharo-Examples/package.st @@ -0,0 +1 @@ +Package { #name : #'Neo-JSON-Pharo-Examples' } diff --git a/repository/Neo-JSON-Pharo-Tests/package.st b/repository/Neo-JSON-Pharo-Tests/package.st new file mode 100644 index 0000000..7e0f6a8 --- /dev/null +++ b/repository/Neo-JSON-Pharo-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'Neo-JSON-Pharo-Tests' } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/methodProperties.json deleted file mode 100644 index 7c23f92..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONBenchmark.class/methodProperties.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "initialize" : "SvenVanCaekenberghe 6/4/2012 18:49", - "read" : "SvenVanCaekenberghe 6/4/2012 17:02", - "write" : "SvenVanCaekenberghe 6/4/2012 17:26", - "writePrettyPrintedRead" : "SvenVanCaekenberghe 6/6/2012 15:07" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/methodProperties.json deleted file mode 100644 index 9fd029a..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONBenchmarkTests.class/methodProperties.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "testObject2" : "SvenVanCaekenberghe 6/10/2012 20:20", - "testPrettyPrinted" : "SvenVanCaekenberghe 1/15/2014 19:29", - "testRead" : "SvenVanCaekenberghe 1/15/2014 19:30", - "testWrite" : "SvenVanCaekenberghe 1/15/2014 19:30" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/methodProperties.json deleted file mode 100644 index 09b61fb..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONMockStream.class/methodProperties.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "class" : { - "on:" : "SvenVanCaekenberghe 6/13/2012 16:25" }, - "instance" : { - "atEnd" : "SvenVanCaekenberghe 6/13/2012 16:23", - "close" : "SvenVanCaekenberghe 6/13/2012 16:23", - "next" : "SvenVanCaekenberghe 6/13/2012 16:22", - "nextPut:" : "SvenVanCaekenberghe 6/13/2012 16:23", - "nextPutAll:" : "SvenVanCaekenberghe 6/13/2012 16:23", - "peek" : "SvenVanCaekenberghe 6/13/2012 16:22", - "peekFor:" : "SvenVanCaekenberghe 12/3/2012 10:53", - "space" : "SvenVanCaekenberghe 6/13/2012 16:23", - "stream:" : "SvenVanCaekenberghe 6/13/2012 16:22" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testParseErrors.st b/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testParseErrors.st deleted file mode 100644 index 69b9ced..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testParseErrors.st +++ /dev/null @@ -1,5 +0,0 @@ -testing -testParseErrors - self should: [ NeoJSONReader fromString: 'zero' ] raise: NeoJSONParseError. - self should: [ NeoJSONReader fromString: '#' ] raise: NeoJSONParseError. - self should: [ NeoJSONReader fromString: '@' ] raise: NeoJSONParseError. \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testStrings.st b/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testStrings.st deleted file mode 100644 index e723db8..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/instance/testStrings.st +++ /dev/null @@ -1,50 +0,0 @@ -testing -testStrings - | reader | - reader := [ :string | (NeoJSONReader on: string readStream) next ]. - self assert: (reader value: '"foo"') equals: 'foo'. - self assert: (reader value: '""') equals: ''. - self assert: (reader value: '"Foo BAR"') equals: 'Foo BAR'. - self - assert: (reader value: '"\u00E9l\u00E8ve en Fran\u00E7ais"') - equals: 'élève en Français'. - self - assert: - (reader - value: - '"\u042F \u043C\u043E\u0436\u0443 \u0457\u0441\u0442\u0438 \u0441\u043A\u043B\u043E, \u0456 \u0432\u043E\u043D\u043E \u043C\u0435\u043D\u0456 \u043D\u0435 \u0437\u0430\u0448\u043A\u043E\u0434\u0438\u0442\u044C."') - equals: - 'Я можу їсти скло, і воно мені не зашкодить.' - decodeFromUTF8. - self assert: (reader value: '"\uD84C\uDF8F"') equals: '𣎏' decodeFromUTF8. - self - assert: (reader value: '"\"\\\/\t\r\n\f\b"') - equals: - (String - withAll: - {$". - $\. - $/. - (Character tab). - (Character cr). - (Character lf). - (Character newPage). - (Character backspace)}). - self - assert: (reader value: '"\"\\\/\t\r\n\f\b"') - equals: - (String - withAll: - {$". - $\. - $/. - (Character tab). - (Character cr). - (Character lf). - (Character newPage). - (Character backspace)}). - self should: [ reader value: '"open' ] raise: NeoJSONParseError. - self should: [ reader value: '"\uAA"' ] raise: NeoJSONParseError. - self should: [ reader value: '"\uZZ"' ] raise: NeoJSONParseError. - self should: [ reader value: '"\x"' ] raise: NeoJSONParseError. - self should: [ reader value: ' " ' ] raise: NeoJSONParseError \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/methodProperties.json deleted file mode 100644 index 19f6020..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONReaderTests.class/methodProperties.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "testArrayOfPoints" : "SvenVanCaekenberghe 6/12/2012 12:32", - "testAssociation" : "SvenVanCaekenberghe 6/12/2012 13:18", - "testBooleans" : "SvenVanCaekenberghe 6/13/2012 14:44", - "testByteArray" : "dkh 11/17/2014 17:54", - "testDate" : "PaulDeBruicker 11/02/2014 19:47", - "testDateAndTime" : "SvenVanCaekenberghe 6/12/2012 12:02", - "testFloats" : "SvenVanCaekenberghe 6/2/2012 21:49", - "testIntegers" : "SvenVanCaekenberghe 6/12/2012 16:08", - "testLists" : "SvenVanCaekenberghe 6/12/2012 16:16", - "testMaps" : "SvenVanCaekenberghe 6/12/2012 16:16", - "testNextStringAsHex" : "SvenVanCaekenberghe 3/24/2014 11:58", - "testNull" : "SvenVanCaekenberghe 6/13/2012 14:29", - "testOrderedCollection" : "SvenVanCaekenberghe 6/13/2012 10:18", - "testOrderedCollectionOfPoints" : "SvenVanCaekenberghe 6/12/2012 12:33", - "testParseErrors" : "SvenVanCaekenberghe 6/12/2012 16:01", - "testPoint" : "SvenVanCaekenberghe 6/12/2012 15:58", - "testPoint1" : "SvenVanCaekenberghe 6/8/2012 14:04", - "testPoint2" : "SebastianHeidbrink 08/05/2013 09:01", - "testPoint3" : "SvenVanCaekenberghe 6/8/2012 14:04", - "testPointUsingAsString" : "SvenVanCaekenberghe 3/24/2014 10:43", - "testPropertyNamesAsSymbols" : "SvenVanCaekenberghe 6/13/2012 10:00", - "testSmallDictionary" : "PaulDeBruicker 11/02/2014 19:25", - "testStrings" : "dkh 11/25/2014 18:44", - "testSymbol" : "SvenVanCaekenberghe 6/12/2012 12:02", - "testTime" : "SvenVanCaekenberghe 6/12/2012 12:02" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/methodProperties.json deleted file mode 100644 index 006cb6f..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject1.class/methodProperties.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "class" : { - "example1" : "dkh 11/17/2014 17:08", - "neoJsonMapping:" : "SvenVanCaekenberghe 6/12/2012 12:34" }, - "instance" : { - "=" : "SvenVanCaekenberghe 6/9/2012 18:45", - "bytes" : "SvenVanCaekenberghe 6/9/2012 18:03", - "bytes:" : "SvenVanCaekenberghe 6/9/2012 18:04", - "hash" : "SvenVanCaekenberghe 6/9/2012 18:46", - "id" : "SvenVanCaekenberghe 6/9/2012 18:02", - "id:" : "SvenVanCaekenberghe 6/9/2012 18:03", - "name" : "SvenVanCaekenberghe 6/9/2012 18:02", - "name:" : "SvenVanCaekenberghe 6/9/2012 18:03", - "points" : "SvenVanCaekenberghe 6/9/2012 18:03", - "points:" : "SvenVanCaekenberghe 6/9/2012 18:04", - "timestamp" : "SvenVanCaekenberghe 6/9/2012 18:03", - "timestamp:" : "SvenVanCaekenberghe 6/9/2012 18:03" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/methodProperties.json deleted file mode 100644 index 8ab70f5..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject2.class/methodProperties.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "class" : { - "benchmark10k" : "SvenVanCaekenberghe 6/10/2012 20:53", - "benchmark10kAsDictionary" : "SvenVanCaekenberghe 6/10/2012 20:54", - "benchmark200k" : "SvenVanCaekenberghe 6/10/2012 20:54", - "benchmark:" : "SvenVanCaekenberghe 6/10/2012 20:52", - "benchmarkAsDictionary:" : "SvenVanCaekenberghe 6/10/2012 20:53", - "example1" : "SvenVanCaekenberghe 6/10/2012 20:04", - "neoJsonMapping:" : "SvenVanCaekenberghe 3/22/2014 10:50" }, - "instance" : { - "=" : "SvenVanCaekenberghe 6/10/2012 20:22", - "asDictionary" : "SvenVanCaekenberghe 6/10/2012 20:47", - "data" : "SvenVanCaekenberghe 6/10/2012 20:04", - "data:" : "SvenVanCaekenberghe 6/10/2012 20:04", - "hash" : "SvenVanCaekenberghe 6/10/2012 20:22", - "height" : "SvenVanCaekenberghe 6/10/2012 20:04", - "height:" : "SvenVanCaekenberghe 6/10/2012 20:04", - "id" : "SvenVanCaekenberghe 6/10/2012 20:04", - "id:" : "SvenVanCaekenberghe 6/10/2012 20:04", - "width" : "SvenVanCaekenberghe 6/10/2012 20:04", - "width:" : "SvenVanCaekenberghe 6/10/2012 20:04" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/methodProperties.json deleted file mode 100644 index 1e56c67..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONTestObject3.class/methodProperties.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "class" : { - "example1" : "SvenVanCaekenberghe 3/22/2014 09:43", - "neoJsonMapping:" : "SvenVanCaekenberghe 3/22/2014 10:50" }, - "instance" : { - "=" : "SvenVanCaekenberghe 3/22/2014 09:45", - "asDictionary" : "SvenVanCaekenberghe 3/22/2014 09:46", - "color" : "SvenVanCaekenberghe 3/22/2014 09:43", - "color:" : "SvenVanCaekenberghe 3/22/2014 09:43", - "transparent" : "SvenVanCaekenberghe 3/22/2014 09:43", - "transparent:" : "SvenVanCaekenberghe 3/22/2014 09:43" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/methodProperties.json deleted file mode 100644 index adfdccc..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadMockStreamTests.class/methodProperties.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "writeRead:" : "SvenVanCaekenberghe 6/13/2012 16:28" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/methodProperties.json deleted file mode 100644 index a578cda..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadPrettyPrintedTests.class/methodProperties.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "testDictionaryOfObject2" : "PaulDeBruicker 11/02/2014 19:16", - "testObject1" : "SvenVanCaekenberghe 6/9/2012 18:49", - "testObject2" : "SvenVanCaekenberghe 8/30/2013 11:05", - "testObject3" : "SvenVanCaekenberghe 3/22/2014 10:59", - "writeRead:" : "SvenVanCaekenberghe 6/4/2012 15:45" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testAsciiOnlyStrings.st b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testAsciiOnlyStrings.st deleted file mode 100644 index 3b7c6c9..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testAsciiOnlyStrings.st +++ /dev/null @@ -1,12 +0,0 @@ -testing -testAsciiOnlyStrings - | objects | - objects := {'foo'. - 'Foo BAR'. - ''. - ' \\'''. - 'élève en Français'. - ('Я можу їсти скло, і воно мені не зашкодить.' - decodeFromUTF8). - ('𣎏' decodeFromUTF8)}. - self assert: (self writeReadAsciiOnly: objects) equals: objects \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testFloats.st b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testFloats.st deleted file mode 100644 index 92e0e2d..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testFloats.st +++ /dev/null @@ -1,7 +0,0 @@ -testing -testFloats - | objects | - objects := { Float pi . 1.0 . -1.0 . 0.0 . 1.5e6 . -1.5e6 . 1.5e-6 . -1.5e-6 }. - (self writeRead: objects) - with: objects - do: [ :first :second | self assert: (first closeTo: second) ] \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testMaps.st b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testMaps.st deleted file mode 100644 index 2f644a6..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testMaps.st +++ /dev/null @@ -1,10 +0,0 @@ -testing -testMaps - | objects | - objects := { - Dictionary new. - Dictionary with: 'x' -> 1. - Dictionary newFromPairs: #( 'foo' true 'bar' false 'zero' 0 'null' nil 'string' 'Hello World!' ) }. - self - assert: (self writeRead: objects) - equals: objects \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testStrings.st b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testStrings.st deleted file mode 100644 index d676fdd..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/instance/testStrings.st +++ /dev/null @@ -1,12 +0,0 @@ -testing -testStrings - | objects | - objects := {'foo'. - 'Foo BAR'. - ''. - ' \\'''. - 'élève en Français'. - ('Я можу їсти скло, і воно мені не зашкодить.' - decodeFromUTF8). - ('𣎏' decodeFromUTF8)}. - self assert: (self writeRead: objects) equals: objects \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/methodProperties.json deleted file mode 100644 index 98004ea..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriteReadTests.class/methodProperties.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "testAsciiOnlyStrings" : "dkh 11/25/2014 18:45", - "testDictionaryOfObject2" : "PaulDeBruicker 11/02/2014 19:16", - "testFloats" : "SvenVanCaekenberghe 6/4/2012 15:51", - "testIntegers" : "SvenVanCaekenberghe 6/4/2012 15:46", - "testLists" : "SvenVanCaekenberghe 6/4/2012 15:51", - "testMaps" : "SvenVanCaekenberghe 6/4/2012 15:53", - "testObject1" : "SvenVanCaekenberghe 6/9/2012 18:48", - "testObject2" : "SvenVanCaekenberghe 8/30/2013 10:12", - "testObject3" : "SvenVanCaekenberghe 3/22/2014 10:14", - "testSpecials" : "SvenVanCaekenberghe 6/4/2012 15:46", - "testStrings" : "dkh 11/25/2014 18:44", - "writeRead:" : "dkh 11/25/2014 15:40", - "writeReadAsciiOnly:" : "dkh 11/25/2014 15:40" } } diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAsciiOnlyStrings.st b/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAsciiOnlyStrings.st deleted file mode 100644 index 8666a7b..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testAsciiOnlyStrings.st +++ /dev/null @@ -1,39 +0,0 @@ -testing -testAsciiOnlyStrings - | writer | - writer := [ :object | - String - streamContents: [ :stream | - (NeoJSONWriter on: stream) - asciiOnly: true; - nextPut: object ] ]. - self - assert: (writer value: 'élève français') - equals: '"\u00E9l\u00E8ve fran\u00E7ais"'. - self assert: (writer value: 'foo') equals: '"foo"'. - self assert: (writer value: 'Foo BAR') equals: '"Foo BAR"'. - self assert: (writer value: '') equals: '""'. - self - assert: - (writer - value: - (String - withAll: - {$". - $\. - $/. - (Character tab). - (Character cr). - (Character lf). - (Character newPage). - (Character backspace)})) - equals: '"\"\\/\t\r\n\f\b"'. - self - assert: - (writer - value: - 'Я можу їсти скло, і воно мені не зашкодить.' - decodeFromUTF8) - equals: - '"\u042F \u043C\u043E\u0436\u0443 \u0457\u0441\u0442\u0438 \u0441\u043A\u043B\u043E, \u0456 \u0432\u043E\u043D\u043E \u043C\u0435\u043D\u0456 \u043D\u0435 \u0437\u0430\u0448\u043A\u043E\u0434\u0438\u0442\u044C."'. - self assert: (writer value: '𣎏' decodeFromUTF8) equals: '"\uD84C\uDF8F"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMaps.st b/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMaps.st deleted file mode 100644 index 685f41d..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testMaps.st +++ /dev/null @@ -1,8 +0,0 @@ -testing -testMaps - | writer | - writer := [ :object | - String streamContents: [ :stream | - (NeoJSONWriter on: stream) nextPut: object ] ]. - self assert: (writer value: (Dictionary newFromPairs: #( 'x' 1 'y' 2))) equals: '{"x":1,"y":2}'. - self assert: (writer value: Dictionary new) equals: '{}'. diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testStrings.st b/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testStrings.st deleted file mode 100644 index dcfda90..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testStrings.st +++ /dev/null @@ -1,38 +0,0 @@ -testing -testStrings - | writer | - writer := [ :object | String streamContents: [ :stream | (NeoJSONWriter on: stream) nextPut: object ] ]. - self assert: (writer value: 'foo') equals: '"foo"'. - self assert: (writer value: 'Foo BAR') equals: '"Foo BAR"'. - self assert: (writer value: '') equals: '""'. - self assert: (writer value: 'élève français') equals: '"élève français"'. - self - assert: - (writer - value: - (String - withAll: - {$". - $\. - $/. - (Character tab). - (Character cr). - (Character lf). - (Character newPage). - (Character backspace)})) - equals: '"\"\\/\t\r\n\f\b"'. - self - assert: - (writer - value: - 'Я можу їсти скло, і воно мені не зашкодить.' - decodeFromUTF8) - equals: - '"' - , - 'Я можу їсти скло, і воно мені не зашкодить.' - decodeFromUTF8 - , '"'. - self - assert: (writer value: '𣎏' decodeFromUTF8) - equals: '"' , '𣎏' decodeFromUTF8 , '"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testTime.st b/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testTime.st deleted file mode 100644 index f28c5fe..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/instance/testTime.st +++ /dev/null @@ -1,10 +0,0 @@ -testing -testTime - | writer | - writer := [ :object | - String streamContents: [ :stream | - (NeoJSONWriter on: stream) - for: Time customDo: [ :mapping | - mapping encoder: [ :time | time print24 ] ]; - nextPut: object ] ]. - self assert: (writer value: (Time hour: 14 minute: 30 second: 8)) equals: '"14:30:08"' \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/methodProperties.json b/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/methodProperties.json deleted file mode 100644 index 153b668..0000000 --- a/repository/Neo-JSON-Tests.package/NeoJSONWriterTests.class/methodProperties.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "testAsciiOnlyStrings" : "dkh 11/25/2014 18:46", - "testAssociation" : "PaulDeBruicker 11/02/2014 19:26", - "testBooleans" : "SvenVanCaekenberghe 6/3/2012 19:56", - "testByteArray" : "dkh 11/17/2014 18:04", - "testDate" : "PaulDeBruicker 11/02/2014 19:47", - "testDateAndTime" : "SvenVanCaekenberghe 6/12/2012 12:02", - "testFloats" : "PaulDeBruicker 11/02/2014 19:48", - "testIntegers" : "SvenVanCaekenberghe 6/2/2012 22:24", - "testLists" : "SvenVanCaekenberghe 6/3/2012 19:39", - "testMaps" : "SvenVanCaekenberghe 6/3/2012 19:40", - "testNextPutStringAsHex" : "SvenVanCaekenberghe 3/24/2014 11:57", - "testNull" : "SvenVanCaekenberghe 6/2/2012 22:23", - "testPoint" : "SvenVanCaekenberghe 6/12/2012 15:58", - "testPoint1" : "SvenVanCaekenberghe 6/8/2012 14:04", - "testPoint2" : "SvenVanCaekenberghe 6/6/2012 17:29", - "testPoint3" : "SvenVanCaekenberghe 6/8/2012 14:04", - "testPointUsingAsString" : "dkh 11/22/2014 09:28", - "testStrings" : "dkh 11/25/2014 18:44", - "testSymbol" : "SvenVanCaekenberghe 6/8/2012 21:56", - "testTime" : "SvenVanCaekenberghe 6/12/2012 12:02" } } diff --git a/repository/Neo-JSON-Tests.package/monticello.meta/categories.st b/repository/Neo-JSON-Tests.package/monticello.meta/categories.st deleted file mode 100644 index dbd3e6b..0000000 --- a/repository/Neo-JSON-Tests.package/monticello.meta/categories.st +++ /dev/null @@ -1 +0,0 @@ -SystemOrganization addCategory: #'Neo-JSON-Tests'! diff --git a/repository/Neo-JSON-Tests.package/monticello.meta/package b/repository/Neo-JSON-Tests.package/monticello.meta/package deleted file mode 100644 index 4b538f4..0000000 --- a/repository/Neo-JSON-Tests.package/monticello.meta/package +++ /dev/null @@ -1 +0,0 @@ -(name 'Neo-JSON-Tests') \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/monticello.meta/version b/repository/Neo-JSON-Tests.package/monticello.meta/version deleted file mode 100644 index fc8044f..0000000 --- a/repository/Neo-JSON-Tests.package/monticello.meta/version +++ /dev/null @@ -1 +0,0 @@ -(name 'Neo-JSON-Tests-dkh.35' message 'Issue #5: have to use UTF8 encoded Strings in method source instead of Unicode strings, because GemStone 2.x does not compile methods with some flavors of MultiByte strings ...' id 'c3f1b9f1-7c61-4217-8a8a-5ac43231db7e' date '11/25/2014' time '18:47:48' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.34' message 'Issue #5: restore a test case' id '3ad4c7ed-9113-456e-8e54-2805cf3f166e' date '11/25/2014' time '16:53:38' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.33' message 'Issue #5: turns out that what was missing from the NeoJSON implementation was the handling of code points greater than 0xFFFF (as noted in my original comment) ... I had misinterpretted the solution to be to use UTF8 encoding ... the proper answer was to use UTF-16 surrogate pairs for code points > 16rFFFF... which I''ve done ' id 'a4c5f489-04e5-4117-981a-27aaadb0c40e' date '11/25/2014' time '16:50:15' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.32' message 'Issue #5: expand test suite to cover Unicode16 and Unicode32 strings. Move String>>neoJsonOn: to CharacterCollection>>neoJsonOn: so that multi-byte strings are covered. Unicode32 string test cases are failing: 74 run, 71 passes, 0 expected defects, 3 failures, 0 errors, 0 unexpected passes 75 tests 74 run [''done''] 71 passes 0 expected defects 3 failures 0 errors 0 unexpected passes ' id '6e050037-a240-4c81-8c3f-c7ff2da8a0f2' date '11/24/2014' time '22:46:28' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.31' message 'tests should be green now ...' id '864dad8d-d957-4166-8a00-13332418f259' date '11/22/2014' time '09:52:42' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.30' message 'Issue #2: and more 2.x portability' id '6ba38801-d919-4243-a27c-c97cdd76a6d8' date '11/17/2014' time '18:04:58' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.29' message 'Issue #2: more 2.x portability' id '609ae8ec-5e5d-4ab0-9025-ef49e5c838c8' date '11/17/2014' time '17:54:53' author 'dkh' ancestors ((name 'Neo-JSON-Tests-dkh.28' message 'Issue #2: getting tests to load in GemStone 2.x' id 'cfae8ad5-56a4-4ac7-8fa0-98f4f676b6ce' date '11/17/2014' time '17:48:36' author 'dkh' ancestors ((name 'Neo-JSON-Tests-PaulDeBruicker.27' message 'One test has an error, all others pass.' id '0cdeaeeb-a2ce-4c3c-9651-4b5338dc3aa3' date '11/02/2014' time '19:54:25' author 'PaulDeBruicker' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.24' message 'Added new feature NeoJSONWriter>>#nextPutAs: symmetrical to NeoJSONReader>>#next:as: Added 4 unit test to exercise the new options' id '4c7461c1-82ea-4126-8b5c-ef307168120a' date '03/24/2014' time '12:19:53' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.23' message 'Added basic support for mapping using inheritance when using #neoJonMapping : (see #testObject3) Renamed #new[Custom|Object]MappingFor: to [custom|object]MappingFor: to better reflect the new behavior Thanks Philippe Back for making these suggestions!' id '27fad240-c6b9-4d00-a4e6-6e49fd612dfb' date '03/22/2014' time '11:04:11' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.22' message 'remove timing assertions from NeoJSONBenchmarkTests sinc they occasionally fail on the CI servers' id '3a07a705-816f-4981-9269-8d20620a00e2' date '01/15/2014' time '07:31:53' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.21' message 'Increase the NeoJSONBenchmarkTests>>#testPrettyPrinter timeout even more' id '90807026-211d-4644-b211-1ea5bfd92bd6' date '12/27/2013' time '09:44:01' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.20' message 'Give NeoJSONBenchmarksTests some more time to finish (on slow CI build slaves)' id 'f5f8f820-40d4-44ea-b5b6-8634e4cb7c5e' date '12/27/2013' time '07:01:23' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.19' message 'New feature: NeoJSONWriter>>#asciiOnly: to escape all non ASCII characters in strings' id 'e1a69fdb-7e41-46f7-9f52-312eae3fab61' date '09/03/2013' time '12:21:56' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.18' message 'Added tests for NeoJSONCustomMapping>>#mapWithValueSchema:' id '3f001444-6572-47d5-b656-96363c695522' date '08/30/2013' time '11:09:49' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.17' message 'Make SmallDictionary optional in NeoJSONReaderTests>>#testSmallDictionary' id '5fa85190-9a4c-4b91-9747-f5e6a547e5ad' date '07/04/2013' time '06:43:12' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.16' message 'add NeoJSONMockStream>>#peekFor:' id 'baadfdb3-b8b4-4ce5-b072-0ebf67edd45f' date '12/03/2012' time '11:14:13' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.15' message 'added code to test the character stream API being used' id '696b4956-43ef-4fb8-a295-aa0bcc16685c' date '06/13/2012' time '04:29:41' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.14' message 'bugfix in NeoJSONReader>>#match:do: ' id '7e664c0d-c5c3-4e64-a784-c274a85a8230' date '06/13/2012' time '02:58:28' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.13' message 'extended NeoJSONReader with settable listClass and mapClass as well as a propertyNamesAsSymbols option extended class and method comments' id '4c90aab7-73c6-47fe-b52f-46954c06bf19' date '06/13/2012' time '11:57:09' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.12' message 'added tests for bogus input' id '50e7e260-7299-4ff8-880b-cbfd7bc8b30a' date '06/12/2012' time '04:20:02' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.11' message 'major simplification: removed NeoJSON[Composite|List|Map]Mapping, all to be handled by blocks in NeoJSONCustomMapping renamed forCustom:do: to for:customDo: accessor based mapping to NeoJSONObjectMapping ' id 'fcdc4252-6e15-4832-984f-84fbe1486163' date '06/12/2012' time '01:36:40' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.10' message 'added another benchmark' id '0f01e8f8-a367-4cb9-b730-1d8c0b411743' date '06/10/2012' time '09:28:30' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.9' message 'added NeoJSONTestObject1 with class side #neoJsonMapping: method' id 'ac3db680-73e6-4358-882c-e237697a7db4' date '06/09/2012' time '06:56:55' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.8' message 'added custom mapping tests' id '015e7c92-0411-4c7f-80b3-2d18a445250e' date '06/08/2012' time '10:10:24' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.7' message 'adding valueSchema to propertyMapping' id '9723e179-f1b9-4641-85ea-45ba89487b07' date '06/08/2012' time '20:36:25' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.6' message '1st version where list mapping works on some simple examples' id '6dbd0ade-2632-42a1-bd3c-45ef3fc0b596' date '06/08/2012' time '16:41:04' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.5' message '1st version with working object mapping for writer' id '59e0739f-bd31-4057-a366-2b5d27cf304c' date '06/06/2012' time '20:47:29' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.4' message 'added NeoJSONBenchmarkTests' id 'f36901e7-bb6d-4d6c-b4e8-5e70db8cce97' date '06/05/2012' time '17:30:17' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.3' message 'added more tests and a simple benchmark' id '5396d3f6-f1f0-46bc-961a-72a5919a9b79' date '06/04/2012' time '18:53:25' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.2' message 'first simple version of NeoJSONWriter' id '4b84c7e9-74d5-4b8b-bf9e-4be5fda1eb10' date '06/03/2012' time '19:58:06' author 'SvenVanCaekenberghe' ancestors ((name 'Neo-JSON-Tests-SvenVanCaekenberghe.1' message 'first simple version of NeoJSONReader' id '6927fec5-5a02-4ad2-8d4a-7be492da47da' date '06/02/2012' time '22:00:14' author 'SvenVanCaekenberghe' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/repository/Neo-JSON-Tests.package/properties.json b/repository/Neo-JSON-Tests.package/properties.json deleted file mode 100644 index f037444..0000000 --- a/repository/Neo-JSON-Tests.package/properties.json +++ /dev/null @@ -1,2 +0,0 @@ -{ - } diff --git a/repository/Neo-JSON-Tests/NeoJSONBenchmark.class.st b/repository/Neo-JSON-Tests/NeoJSONBenchmark.class.st new file mode 100644 index 0000000..e436ea4 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONBenchmark.class.st @@ -0,0 +1,73 @@ +" +I am NeoJSONBenchmark. +I hold 1000 objects of the form Dictionary('color'->'green' 'enabled'->false 'id'->1 'name'->'Name-1' 'value'->0.002 ) in an Array. +I hold the JSON serialization of that as a String of the form '[{""value"":0.002,""enabled"":false,""name"":""Name-1"",""color"":""green"",""id"":1}, ... + +| benchmark | +benchmark := NeoJSONBenchmark new. +[benchmark read] bench. + +| benchmark | +benchmark := NeoJSONBenchmark new. +[benchmark write] bench. + +| benchmark | +benchmark := NeoJSONBenchmark new. +[benchmark read] timeToRun. + +| benchmark | +benchmark := NeoJSONBenchmark new. +[benchmark write] timeToRun. +" +Class { + #name : 'NeoJSONBenchmark', + #superclass : 'Object', + #instVars : [ + 'objects', + 'json' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'initialize-release' } +NeoJSONBenchmark >> initialize [ + super initialize. + objects := Array new: 1000. + 1 to: 1000 do: [ :each | + | map | + (map := Dictionary new) + at: 'id' put: each; + at: 'name' put: 'Name-', each asString; + at: 'enabled' put: (#( true false) at: (each \\ 2) + 1); + at: 'color' put: (#( 'red' 'green' 'blue' ) at: (each \\ 3) + 1); + at: 'value' put: each + each / 1000.0. + objects at: each put: map ]. + json := String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: objects ] + +] + +{ #category : 'public' } +NeoJSONBenchmark >> read [ + ^ (NeoJSONReader on: json readStream) next + +] + +{ #category : 'public' } +NeoJSONBenchmark >> write [ + ^ String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: objects ] + +] + +{ #category : 'public' } +NeoJSONBenchmark >> writePrettyPrintedRead [ + | output | + output := String streamContents: [ :stream | + (NeoJSONWriter on: stream) + prettyPrint: true; + nextPut: objects ]. + ^ (NeoJSONReader on: output readStream) + next +] diff --git a/repository/Neo-JSON-Tests/NeoJSONBenchmarkTests.class.st b/repository/Neo-JSON-Tests/NeoJSONBenchmarkTests.class.st new file mode 100644 index 0000000..549e715 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONBenchmarkTests.class.st @@ -0,0 +1,43 @@ +" +I am NeoJSONBenchmarkTests. + +This test is obviously dependent on hardware, but the margin is quite high. +" +Class { + #name : 'NeoJSONBenchmarkTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONBenchmarkTests >> testObject2 [ + | json | + json := NeoJSONWriter toString: NeoJSONTestObject2 new. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject2) + equals: NeoJSONTestObject2 new +] + +{ #category : 'testing' } +NeoJSONBenchmarkTests >> testPrettyPrinted [ + | benchmark | + benchmark := NeoJSONBenchmark new. + self + assert: benchmark writePrettyPrintedRead + equals: benchmark read +] + +{ #category : 'testing' } +NeoJSONBenchmarkTests >> testRead [ + | benchmark | + benchmark := NeoJSONBenchmark new. + benchmark read +] + +{ #category : 'testing' } +NeoJSONBenchmarkTests >> testWrite [ + | benchmark | + benchmark := NeoJSONBenchmark new. + benchmark write +] diff --git a/repository/Neo-JSON-Tests/NeoJSONExamplesTests.class.st b/repository/Neo-JSON-Tests/NeoJSONExamplesTests.class.st new file mode 100644 index 0000000..f4f2b6c --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONExamplesTests.class.st @@ -0,0 +1,119 @@ +" +NeoJSONExamplesTests runs a couple of examples as tests +" +Class { + #name : 'NeoJSONExamplesTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'tests' } +NeoJSONExamplesTests >> testMultiInstances [ + "Newline delimited JSON (application/x-ndjson) - https://github.com/ndjson/ndjson-spec" + "JSON Lines (application/jsonl) - https://jsonlines.org" + + | data json | + + data := (1 to: 10) collect: [ :each | + { #number -> each } asDictionary ]. + + json := String streamContents: [ :out | + (NeoJSONWriter on: out) nextPutAll: data ]. + + self assert: (NeoJSONReader on: json readStream) upToEnd equals: data. + + self assert: (NeoJSONReader on: json readStream) next equals: data first. + self deny: ((NeoJSONReader on: json readStream) next; atEnd) +] + +{ #category : 'tests' } +NeoJSONExamplesTests >> testPoints [ + | points json result | + + points := Array with: 1@2 with: 3@4 with: 5@6. + + json := String streamContents: [ :out | + (NeoJSONWriter on: out) + prettyPrint: true; + mapInstVarsFor: Point; + nextPut: points ]. + + result := (NeoJSONReader on: json readStream) + mapInstVarsFor: Point; + for: #ListOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]; + nextAs: #ListOfPoints. + + self assert: result equals: points. + + result := (NeoJSONReader on: json readStream) + mapInstVarsFor: Point; + nextListAs: Point. + + self assert: result equals: points. + + result := (NeoJSONReader on: json readStream) + mapInstVarsFor: Point; + for: #OrderedCollectionOfPoints customDo: [ :mapping | + mapping listOfType: OrderedCollection andElementSchema: Point ]; + nextAs: #OrderedCollectionOfPoints. + + self assert: result equals: points asOrderedCollection. +] + +{ #category : 'tests' } +NeoJSONExamplesTests >> testRectanglePoints [ + | rectangle rectangleJson result | + + rectangle := Rectangle origin: 3 @ 4 extent: 5 @ 6. + + rectangleJson := String streamContents: [ :stream | + (NeoJSONWriter on: stream) + prettyPrint: true; + mapInstVarsFor: Point; + mapInstVarsFor: Rectangle; + nextPut: rectangle ]. + + result := (NeoJSONReader on: rectangleJson readStream) + mapInstVarsFor: Point; + for: Rectangle do: [ :mapping | + (mapping mapInstVar: #origin) valueSchema: Point. + (mapping mapInstVar: #corner) valueSchema: Point ]; + nextAs: Rectangle. + + self assert: result equals: rectangle. + + result := (NeoJSONReader on: rectangleJson readStream) + mapInstVarsFor: Point; + for: Rectangle do: [ :mapping | + mapping mapInstVars do: [ :each | each valueSchema: Point ] ]; + nextAs: Rectangle. + + self assert: result equals: rectangle +] + +{ #category : 'tests' } +NeoJSONExamplesTests >> testRectanglePointsWithNils [ + self + assert: + (String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Point do: [ :mapping | mapping mapAllInstVars ]; + for: Rectangle do: [ :mapping | + (mapping mapInstVar: #origin) valueSchema: Point. + (mapping mapInstVar: #corner) valueSchema: Point ]; + nextPut: Rectangle new ]) + equals: '{}'. + self + assert: + (String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Point do: [ :mapping | mapping mapAllInstVars ]; + for: Rectangle do: [ :mapping | + (mapping mapInstVar: #origin) valueSchema: Point. + (mapping mapInstVar: #corner) valueSchema: Point ]; + writeNil: true; + nextPut: Rectangle new ]) + equals: '{"origin":null,"corner":null}'. +] diff --git a/repository/Neo-JSON-Tests/NeoJSONFloatPrinterTests.class.st b/repository/Neo-JSON-Tests/NeoJSONFloatPrinterTests.class.st new file mode 100644 index 0000000..eadef2a --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONFloatPrinterTests.class.st @@ -0,0 +1,108 @@ +" +I am NeoJSONFloatPrinterTests, the collection of unit tests for NeoJSONFloatPrinter. +" +Class { + #name : 'NeoJSONFloatPrinterTests', + #superclass : 'TestCase', + #instVars : [ + 'printer' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'running' } +NeoJSONFloatPrinterTests >> setUp [ + super setUp. + printer := NeoJSONFloatPrinter new +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testDecimalNotation [ + self assert: (printer print: 1.5) equals: '1.5'. + self assert: (printer print: -1.5) equals: '-1.5'. + self assert: (printer print: 0.5) equals: '0.5'. + self assert: (printer print: -0.5) equals: '-0.5'. + self assert: (printer print: (1/3) asFloat) equals: '0.33333'. + self assert: (printer print: (-1/3) asFloat) equals: '-0.33333'. + self assert: (printer print: 0.00123) equals: '0.00123'. + self assert: (printer print: -0.00123) equals: '-0.00123'. + self assert: (printer print: 0.00012) equals: '0.00012'. + self assert: (printer print: -0.00012) equals: '-0.00012'. + self assert: (printer print: 123456.12345) equals: '123456.12345'. + self assert: (printer print: -123456.12345) equals: '-123456.12345'. + +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testInteger [ + self assert: (printer print: 1.0) equals: '1'. + self assert: (printer print: 0.0) equals: '0'. + self assert: (printer print: -1.0) equals: '-1'. + self assert: (printer print: 123.0) equals: '123'. + self assert: (printer print: 123456.0) equals: '123456'. + +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testLowPrecision [ + printer := NeoJSONFloatPrinter lowPrecision. + self assert: (printer print: (4/3) asFloat) equals: '1.33'. + self assert: (printer print: 12345.66) equals: '12345.66'. + self assert: (printer print: -123456.77) equals: '-1.23e5'. + self assert: (printer print: Float pi) equals: '3.14'. + self assert: (printer print: Float e negated) equals: '-2.72'. + "the earth's mass in kg" + self assert: (printer print: 5.9724e24) equals: '5.97e24'. + "mass of electron in kg" + self assert: (printer print: 9.10938356e-31) equals: '9.11e-31'. +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testScientificNotation [ + self assert: (printer print: 1234567.5) equals: '1.23457e6'. "note the rounding" + self assert: (printer print: -1234567.5) equals: '-1.23457e6'. "note the rounding" + self assert: (printer print: 0.0000123) equals: '1.23e-5'. + self assert: (printer print: -0.0000123) equals: '-1.23e-5'. + +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testScientificOnly [ + printer := NeoJSONFloatPrinter scientificOnly. + self assert: (printer print: (4/3) asFloat) equals: '1.33333e0'. + self assert: (printer print: 12345.66) equals: '1.23457e4'. + self assert: (printer print: Float pi) equals: '3.14159e0'. + self assert: (printer print: Float e negated) equals: '-2.71828e0'. + "the earth's mass in kg" + self assert: (printer print: 5.9724e24) equals: '5.9724e24'. + "mass of electron in kg" + self assert: (printer print: 9.10938356e-31) equals: '9.10938e-31'. +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testSpecialValues [ + self assert: (printer print: Float zero) equals: '0'. + self assert: (printer print: Float nan) equals: 'NaN'. + self assert: (printer print: Float infinity) equals: 'Inf'. + self assert: (printer print: Float infinity negated) equals: '-Inf'. +] + +{ #category : 'tests' } +NeoJSONFloatPrinterTests >> testWellKnownConstants [ + self assert: (printer print: Float pi) equals: '3.14159'. + self assert: (printer print: Float e) equals: '2.71828'. + "the earth's mass in kg" + self assert: (printer print: 5.9724e24) equals: '5.9724e24'. + "mass of electron in kg" + self assert: (printer print: 9.10938356e-31) equals: '9.10938e-31'. + "planck's constant in Js" + self assert: (printer print: 1.05457e-34) equals: '1.05457e-34'. + "speed of light in m/s" + self assert: (printer print: 2.99792e8) equals: '2.99792e8'. + "charge of electron in C" + self assert: (printer print: -1.60218e-19) equals: '-1.60218e-19'. + "boltzmann's constant in J/K" + self assert: (printer print: 1.38065e-23) equals: '1.38065e-23'. + +] diff --git a/repository/Neo-JSON-Tests/NeoJSONMappingTests.class.st b/repository/Neo-JSON-Tests/NeoJSONMappingTests.class.st new file mode 100644 index 0000000..93488eb --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONMappingTests.class.st @@ -0,0 +1,87 @@ +" +I am NeoJSONMappingTests, testing more exotic kinds of mapping constructs. +" +Class { + #name : 'NeoJSONMappingTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONMappingTests >> testDynamicTyping [ + | data customMapping json result | + data := Array with: 'foo'->1 with: #('foo' 2). + "The idea is to map a key value combination as either a classic association or a simple pair, + using key & value properties as well as a type property to distinguish between the two" + customMapping := [ :mapper | + mapper + for: #AssocOrPair customDo: [ :mapping | + mapping + encoder: [ :x | + x isArray + ifTrue: [ Dictionary new at: 'type' put: 'pair'; at: 'key' put: x first; at: 'value' put: x second; yourself ] + ifFalse: [ Dictionary new at: 'type' put: 'assoc'; at: 'key' put: x key; at: 'value' put: x value; yourself ] ]; + decoder: [ :x | + (x at: 'type') = 'pair' + ifTrue: [ Array with: (x at: 'key') with: (x at: 'value') ] + ifFalse: [ (x at: 'key') -> (x at: 'value')] ] ]; + for: #ArrayOfAssocOrPair customDo: [ :mapping | + mapping listOfType: Array andElementSchema: #AssocOrPair ]; + yourself ]. + json := String streamContents: [ :out | + (customMapping value: (NeoJSONWriter on: out)) nextPut: data as: #ArrayOfAssocOrPair ]. + result := (customMapping value: (NeoJSONReader on: json readStream)) nextAs: #ArrayOfAssocOrPair. + self assert: result equals: data +] + +{ #category : 'testing' } +NeoJSONMappingTests >> testSymbolOrStringInstVarMapping [ + | data out1 out2 result1 result2 | + data := Array with: 1@2 with: 3@4. + out1 := String streamContents: [ :out | + (NeoJSONWriter on: out) + for: Point do: [ :mapping | mapping mapInstVars: #(x y) ]; + nextPut: data ]. + result1 := (NeoJSONReader on: out1 readStream) + for: Point do: [ :mapping | mapping mapInstVars: #(x y) ]; + nextListAs: Point. + self assert: result1 equals: data. + out2 := String streamContents: [ :out | + (NeoJSONWriter on: out) + for: Point do: [ :mapping | mapping mapInstVars: #('x' 'y') ]; + nextPut: data ]. + result2 := (NeoJSONReader on: out1 readStream) + for: Point do: [ :mapping | mapping mapInstVars: #('x' 'y') ]; + nextListAs: Point. + self assert: result2 equals: data +] + +{ #category : 'testing' } +NeoJSONMappingTests >> testVirtualTransferObject [ + | data customMapping extraJson json result | + data := NeoJSONObject new data: (Array with: 1@1 with: 2@2). + extraJson := '{"foo":1,"data":[{"x":1,"y":1},{"x":2,"y":2,"z":-1}]}'. + "The idea here is that we are not interested in the top level object just in its data property, + which should be of a specific type, hence we create a virtual transfer object" + customMapping := [ :mapper | + mapper + for: Point do: [ :mapping | + mapping mapInstVars: #(x y) ]; + for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]; + for: #TransferObject do: [ :mapping | + mapping subjectClass: NeoJSONObject. + (mapping mapAccessor: #data) valueSchema: #ArrayOfPoints ]; + yourself ]. + "By using NeoJSONObject accessors (#data & #data:) are translated to generic #at:[put:] messages. + A longer alternative is + (mapping mapProperty: #data getter: [ :obj | obj at: #data ] setter: [ :obj :x | obj at: #data put: x]) valueSchema: #ArrayOfPoints + where the blocks give you the flexibility to use a plain Dictionary for example" + result := (customMapping value: (NeoJSONReader on: extraJson readStream)) nextAs: #TransferObject. + self assert: result equals: data. + json := String streamContents: [ :out | + (customMapping value: (NeoJSONWriter on: out)) nextPut: data as: #TransferObject ]. + result := (customMapping value: (NeoJSONReader on: json readStream)) nextAs: #TransferObject. + self assert: result equals: data +] diff --git a/repository/Neo-JSON-Tests/NeoJSONMockStream.class.st b/repository/Neo-JSON-Tests/NeoJSONMockStream.class.st new file mode 100644 index 0000000..7b6b18f --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONMockStream.class.st @@ -0,0 +1,70 @@ +" +I am NeoJSONMockStream. +I wrap another stream to validate the limited API used. +" +Class { + #name : 'NeoJSONMockStream', + #superclass : 'Object', + #instVars : [ + 'stream' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'instance creation' } +NeoJSONMockStream class >> on: stream [ + ^ self new + stream: stream; + yourself +] + +{ #category : 'testing' } +NeoJSONMockStream >> atEnd [ + ^ stream atEnd +] + +{ #category : 'accessing' } +NeoJSONMockStream >> close [ + ^ stream close +] + +{ #category : 'accessing' } +NeoJSONMockStream >> collectionSpecies [ + ^ stream collectionSpecies +] + +{ #category : 'accessing' } +NeoJSONMockStream >> next [ + ^ stream next +] + +{ #category : 'accessing' } +NeoJSONMockStream >> nextPut: character [ + ^ stream nextPut: character +] + +{ #category : 'accessing' } +NeoJSONMockStream >> nextPutAll: string [ + ^ stream nextPutAll: string +] + +{ #category : 'accessing' } +NeoJSONMockStream >> peek [ + ^ stream peek +] + +{ #category : 'accessing' } +NeoJSONMockStream >> peekFor: char [ + ^ stream peekFor: char +] + +{ #category : 'accessing' } +NeoJSONMockStream >> space [ + ^ stream space +] + +{ #category : 'initialize-release' } +NeoJSONMockStream >> stream: anObject [ + stream := anObject +] diff --git a/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st b/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st new file mode 100644 index 0000000..db8c0d0 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONObjectTests.class.st @@ -0,0 +1,202 @@ +" +I am NeoJSONObjectTests, I hold unit tests for NeoJSONObject. + +" +Class { + #name : 'NeoJSONObjectTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'accessing' } +NeoJSONObjectTests >> exampleJSONSchema [ + ^ NeoJSONObject fromString: '{ + "$id" : "https://example.com/schemas/address", + "type" : "object", + "properties" : { + "street_address" : { "$anchor" : "street_address", "type" : "string" }, + "city" : { "type" : "string" }, + "state" : { "type" : "string" } + }, + "required" : ["street_address", "city", "state"], + "$defs" : { + "country" : { "type" : "object", "$anchor" : "country", "enum" : ["us","canada","gb"] } + } +}' +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testArray [ + | jsonArray array | + jsonArray := '[1,2,3]'. + array := NeoJSONObject fromString: jsonArray. + self assert: array asString equals: jsonArray. + self assertCollection: array hasSameElements: #(1 2 3). + array at: 1 add: 0. + array at: #- add: 4. + self assertCollection: array hasSameElements: #(0 1 2 3 4). + array removeKey: 5. + array removeKey: 1. + self assertCollection: array hasSameElements: #(1 2 3) +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testAtAt [ + | object | + object := NeoJSONObject new. + self assert: (object at: #foo) isNil. + self assert: (object at: #foo at: #bar) isNil. + object at: #foo at: #bar put: 123. + self assert: (object at: #foo) notNil. + self assert: (object at: #foo at: #bar) equals: 123. + self assert: object foo bar equals: 123. + object at: #foo at: #bar put: -1. + self assert: (object at: #foo at: #bar) equals: -1. + self assert: (object at: #foo at: #foo) isNil +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testAtPath [ + | object | + object := NeoJSONObject newFrom: (Array with: #one -> ( NeoJSONObject newFrom: (Array with: #two -> ( NeoJSONObject newFrom: (Array with: #three -> 42) ) ) )). + self assert: (object atPath: #(one two three)) equals: 42. + self assert: (object atPath: #(one two three)) equals: object one two three. + self assert: (object atPath: #(missing)) equals: nil. + self assert: (object atPath: #(one missing)) equals: nil. + self assert: (object atPath: #(one two missing)) equals: nil. + self assert: (object atPath: #(one two missing)) equals: object one two missing. + + object := NeoJSONObject newFrom: (Array with: #foo -> 42). + self assert: (object atPath: #(foo)) equals: 42. + self assert: (object atPath: #(foo)) equals: object foo. + self assert: (object atPath: #(foo)) equals: (object at: #foo). + self assert: (object atPath: #()) equals: object. + + +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testAtPathPut [ + | object | + object := NeoJSONObject new. + object atPath: #(one test) put: 42. + self assert: (object atPath: #(one test)) equals: 42. + self assert: object one test equals: 42. + object atPath: #(one two three) put: #foo. + self assert: (object atPath: #(one two three)) equals: #foo. + self assert: object one two three equals: #foo. + object atPath: #(one two threeBis) put: #bar. + self assert: (object atPath: #(one two threeBis)) equals: #bar. + self assert: object one two threeBis equals: #bar. + + self assert: object foo isNil. + self assert: (object atPath: #() put: 1) equals: object. + self assert: (object atPath: #(foo) put: 1) equals: 1. + self assert: (object atPath: #(foo)) equals: 1. + self assert: object foo equals: 1 + + +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testCRUD [ + | object | + object := NeoJSONObject new. + self assert: object isEmpty. + self assert: object foo equals: nil. + object foo: 123. + self assert: object foo equals: 123. + self assert: object printString equals: '{"foo":123}'. + object name: 'test'. + object value: Float pi. + self assert: object name equals: 'test'. + self assert: (object value closeTo: Float pi). + self assert: object keys asSet equals: #(foo name value) asSet. + object removeKey: #foo. + self assert: object foo equals: nil. + object removeAll. + self assert: object isEmpty +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testFindPath [ + | json path | + json := self exampleJSONSchema. + + path := json findPath: [ :object | object isDictionary and: [ (object at: '$anchor') = 'street_address' ] ]. + self deny: path isNil. + self assert: path equals: #(properties street_address). + self assert: ((json atPath: path) at: '$anchor') equals: 'street_address'. + + path := json findPath: [ :object | object isDictionary and: [ (object at: 'foo') = 'bar' ] ]. + self assert: path isNil. + + path := json findPath: [ :object | object isDictionary and: [ (object at: '$anchor') = 'country' ] ]. + self deny: path isNil. + self assert: path equals: #('$defs' country). + self assert: ((json atPath: path) at: '$anchor') equals: 'country'. + + json := NeoJSONObject new at: '$anchor' put: 'top'; yourself. + self + assert: (json findPath: [ :object | object isDictionary and: [ (object at: '$anchor') = 'top' ] ]) + equals: #(()) +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testFindPaths [ + | json paths | + json := self exampleJSONSchema. + + paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: '$anchor' ] ]. + self deny: paths isEmpty. + self assert: paths asArray equals: #((properties street_address) ('$defs' country)). + self assert: ((json atPath: paths first) at: '$anchor') equals: 'street_address'. + self assert: ((json atPath: paths second) at: '$anchor') equals: 'country'. + + paths := json findPaths: [ :object | object isDictionary and: [ (object at: 'foo') = 'bar' ] ]. + self assert: paths isEmpty. + + paths := json findPaths: [ :object | object isDictionary and: [ object includesKey: #type ] ]. + self deny: paths isEmpty. + paths do: [ :path | + self assert: (#(string object) includes: ((json atPath: path) at: #type)) ]. + + paths := json findPaths: [ :_ | true ]. + paths do: [ :each | + self assert: (json atPath: each) notNil ] +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testJSON [ + | data json object | + data := NeoJSONObject newFrom: (Array with: #foo->1 with: #bar->2 with: #str->'Str!' with: #bool->true with: #flt->1.5). + json := NeoJSONWriter toString: data . + object := NeoJSONObject fromString: json. + self assert: object class equals: NeoJSONObject. + self assert: object equals: data. + json := (NeoJSONWriter toString: object). + self assert: (NeoJSONObject fromString: json) equals: object +] + +{ #category : 'testing' } +NeoJSONObjectTests >> testPathAccess [ + | data | + data := NeoJSONObject fromString: '{"foo":1,"bar":2,"array":[{"a":1},{"b":2}]}'. + self assert: (data atPath: #(array 1 a)) equals: 1. + self assert: (data atPath: #(array 2 b)) equals: 2. + self assert: (data atPath: #(missing 1)) equals: nil. + data atPath: #(missing) put: 7. + self assert: (data atPath: #(missing)) equals: 7. + self assert: (data atPath: #(array 3)) equals: nil. + data := NeoJSONObject fromString: '[{"c":1},{"c":2},{"c":3}]'. + self assert: (data atPath: #(2 c)) equals: 2. + self assert: (data atPath: #(10 c)) equals: nil. + self assert: (data atPath: #(3 missing)) equals: nil. + data atPath: #(3 missing) put: #found. + self assert: (data atPath: #(3 missing)) equals: #found. + (data at: 3) removeKey: #missing. + self assert: (data atPath: #(3 missing)) equals: nil. + data atPath: #(3 missing x) put: #found. + self assert: (data atPath: #(3 missing x)) equals: #found. +] diff --git a/repository/Neo-JSON-Tests/NeoJSONReaderTests.class.st b/repository/Neo-JSON-Tests/NeoJSONReaderTests.class.st new file mode 100644 index 0000000..3c472c4 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONReaderTests.class.st @@ -0,0 +1,416 @@ +" +I am NeoJSONReaderTests, a test suite for NeoJSONReader. +" +Class { + #name : 'NeoJSONReaderTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONReaderTests >> testAllowNil [ + self + should: [ + (NeoJSONReader on: 'null' readStream) + mapInstVarsFor: Point; + nextAs: Point ] + raise: NeoJSONParseError. + self + assert: ((NeoJSONReader on: 'null' readStream) + mapInstVarsFor: Point; + for: Point do: [ :mapping | mapping allowNil ]; + nextAs: Point) + equals: nil. + self + assert: ((NeoJSONReader on: '[ { "x" : 1, "y" : 2 }, null, { "x" : 3, "y" : -1 } ]' readStream) + mapInstVarsFor: Point; + for: Point do: [ :mapping | mapping allowNil ]; + for: #ArrayOfPoints customDo: [ :mapping | mapping listOfElementSchema: Point ]; + nextAs: #ArrayOfPoints) + equals: (Array with: 1 @ 2 with: nil with: 3 @ -1). +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testArrayOfPoints [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + for: Point do: [ :mapping | + mapping mapInstVars: #(x y) ]; + for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]; + nextAs: #ArrayOfPoints ]. + self assert: (reader value: '[ { "x":1, "y":2 }, { "x":-1, "y":-2 } ]') equals: (Array with: 1@2 with: -1@ -2) . + self assert: (reader value: '[ ]') equals: #(). + self assert: (reader value: '[ { } ]') equals: (Array with: Point new) +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testArrayOfPointsUsingNextListAs [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + mapInstVarsFor: Point; + nextListAs: Point ]. + self assert: (reader value: '[ { "x":1, "y":2 }, { "y":-2, "x":-1 } ]') equals: (Array with: 1@2 with: -1@ -2) . + self assert: (reader value: '[ ]') equals: #(). + self assert: (reader value: '[ { } ]') equals: (Array with: Point new) +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testAssociation [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + for: Association do: [ :mapping | + mapping mapAccessors: #(key value) ]; + nextAs: Association ]. + self assert: (reader value: '{"key":"foo","value":42}') equals: 'foo' -> 42. + self assert: (reader value: '{}') equals: Association new +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testBooleans [ + self assert: (NeoJSONReader on: 'true' readStream) next equals: true. + self assert: (NeoJSONReader on: 'false' readStream) next equals: false. + self should: [ (NeoJSONReader on: 'tru' readStream) next ] raise: NeoJSONParseError. + self should: [ (NeoJSONReader on: 'falsE' readStream) next ] raise: NeoJSONParseError. +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testByteArray [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + for: ByteArray customDo: [ :mapping | + mapping listOfType: ByteArray ]; + nextAs: ByteArray ]. + self assert: (reader value: '[ 1, 2, 3 ]') equals: #[1 2 3]. + self assert: (reader value: '[ ]') equals: ByteArray new +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testDate [ + | reader | + reader := [ :input | + (NeoJSONReader on: input readStream) + for: Date customDo: [ :mapping | + mapping decoder: [ :string | Date fromString: string ] ]; + nextAs: Date ]. + self assert: (reader value: ' "2012-06-08" ') equals: (Date fromString: '2012-06-08') +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testDateAndTime [ + | reader | + reader := [ :input | + (NeoJSONReader on: input readStream) + for: DateAndTime customDo: [ :mapping | + mapping decoder: [ :string | DateAndTime fromString: string ] ]; + nextAs: DateAndTime ]. + self + assert: (reader value: ' "2012-02-14T16:40:18+01:00" ') + equals: (DateAndTime year: 2012 month: 2 day: 14 hour: 16 minute: 40 second: 18 offset: 1 hour) +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testFloats [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) next ]. + self assert: ((reader value: '123.0') closeTo: 123.0). + self assert: ((reader value: '-123.0') closeTo: -123.0). + self assert: ((reader value: '123.0e0') closeTo: 123.0). + self assert: ((reader value: '123e6') closeTo: 123e6). + self assert: ((reader value: '123e+6') closeTo: 123e6). + self assert: ((reader value: '123e-6') closeTo: 123e-6). + self assert: ((reader value: '123E6') closeTo: 123e6). + self assert: ((reader value: '123E+6') closeTo: 123e6). + self assert: ((reader value: '123E-6') closeTo: 123e-6). + self assert: ((reader value: '-123e6') closeTo: -123e6). + self assert: ((reader value: '-123e-6') closeTo: -123e-6). + self assert: ((reader value: '-123E6') closeTo: -123e6). + self assert: ((reader value: '-123E-6') closeTo: -123e-6). + self assert: ((reader value: '3.141592653589793') closeTo: Float pi). + self assert: ((reader value: '0.123e6') closeTo: 0.123e6). + self assert: ((reader value: '0.123e-6') closeTo: 0.123e-6). + self assert: ((reader value: '-0.123E6') closeTo: -0.123e6). + self assert: ((reader value: '-0.123E-6') closeTo: -0.123e-6). + +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testIntegers [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) next ]. + self assert: (reader value: '123') equals: 123. + self assert: (reader value: '00123') equals: 123. + self assert: (reader value: '-123') equals: -123. + self assert: (reader value: '-0123') equals: -123. + self assert: (reader value: '0') equals: 0. + self assert: (reader value: '-0') equals: 0. + self assert: (reader value: '00') equals: 0. + self assert: (reader value: ' 123 ') equals: 123. + self should: [ reader value: '+1' ] raise: NeoJSONParseError. + self should: [ reader value: ' - ' ] raise: NeoJSONParseError. + +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testLists [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) next ]. + self assert: (reader value: '[1,2,3]') equals: #(1 2 3). + self assert: (reader value: '[]') equals: #(). + self assert: (reader value: ' [ 1 , 2 , 3 ] ') equals: #(1 2 3). + self assert: (reader value: ' [ ] ') equals: #(). + self should: [ reader value: '[1,]' ] raise: NeoJSONParseError. + self should: [ reader value: '[' ] raise: NeoJSONParseError. + self should: [ reader value: ']' ] raise: NeoJSONParseError. + self should: [ reader value: '[}' ] raise: NeoJSONParseError +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testMaps [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) next ]. + self assert: (reader value: '{"x":1,"y":2}') equals: (Dictionary newFromPairs: #( 'x' 1 'y' 2)). + self assert: (reader value: '{}') equals: Dictionary new. + self assert: (reader value: ' { "x" : 1 , "y" : 2 } ' ) equals: (Dictionary newFromPairs: #( 'x' 1 'y' 2)). + self assert: (reader value: ' { } ') equals: Dictionary new. + self should: [ reader value: '{"foo":}' ] raise: NeoJSONParseError. + self should: [ reader value: '{"foo":9,}' ] raise: NeoJSONParseError. + self should: [ reader value: '{9:true,}' ] raise: NeoJSONParseError. + self should: [ reader value: '{' ] raise: NeoJSONParseError. + self should: [ reader value: '}' ] raise: NeoJSONParseError. + self should: [ reader value: '{]' ] raise: NeoJSONParseError +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testNextStringAsHex [ + | string | + string := (NeoJSONReader on: '"466F6F2062617221"' readStream) + for: #StringAsHex + customDo: [ :mapping | + mapping + encoder: [ :x | x asByteArray hex asUppercase ]; + decoder: [ :x | (ByteArray readHexFrom: x) asString ] ]; + nextAs: #StringAsHex. + self assert: string equals: 'Foo bar!' +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testNonBMPCharacterDecoding [ + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + + | string object | + string := 16r1D11E asCharacter asString. "MUSICAL SYMBOL G CLEF" + object := (NeoJSONReader fromString: '"\uD834\uDD1E"'). + self assert: object equals: string. + + "UTF-16 surrogate pairs might be invalid, make sure an error is raised" + self should: [ NeoJSONReader fromString: '"\udbff\ue000"' ] raise: NeoJSONParseError +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testNull [ + self assert: (NeoJSONReader on: 'null' readStream) next equals: nil. + self assert: (NeoJSONReader on: ' null ' readStream) next equals: nil. + self should: [ (NeoJSONReader on: ' nil ' readStream) next ] raise: NeoJSONParseError. +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testOrderedCollection [ + | json list | + json := '[ 1, 2, 3 ]'. + list := (NeoJSONReader on: json readStream) + listClass: OrderedCollection; + next. + self + assert: list + equals: (OrderedCollection with: 1 with: 2 with: 3). + self + assert: list class + equals: OrderedCollection +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testOrderedCollectionOfPoints [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + for: Point do: [ :mapping | + mapping mapInstVars: #(x y) ]; + for: #OrderedCollectionOfPoints customDo: [ :mapping | + mapping listOfType: OrderedCollection andElementSchema: Point ]; + nextAs: #OrderedCollectionOfPoints ]. + self assert: (reader value: '[ { "x":1, "y":2 }, { "x":-1, "y":-2 } ]') equals: (Array with: 1@2 with: -1@ -2) asOrderedCollection. + self assert: (reader value: '[ ]') equals: OrderedCollection new. + self assert: (reader value: '[ { } ]') equals: (OrderedCollection with: Point new) +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testParseErrors [ + self should: [ NeoJSONReader fromString: 'zero' ] raise: NeoJSONParseError. + self should: [ NeoJSONReader fromString: '#' ] raise: NeoJSONParseError. + self should: [ NeoJSONReader fromString: '@' ] raise: NeoJSONParseError. + + self should: [ (NeoJSONReader on: '[1,2,3]true' readStream) next; failIfNotAtEnd ] raise: NeoJSONParseError. + self should: [ (NeoJSONReader on: '{"foo":1}"extra"' readStream) next; failIfNotAtEnd ] raise: NeoJSONParseError. + self should: [ (NeoJSONReader on: '[]"extra"' readStream) next; failIfNotAtEnd ] raise: NeoJSONParseError. +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testPoint [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) nextAs: Point ]. + self should: [ reader value: '{"x":1,"y":2}' ] raise: NeoJSONMappingNotFound +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testPoint1 [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + for: Point do: [ :mapping | + mapping mapProperty: 'x' getter: [ :point | point x ] setter: [ :point :value | point setX: value setY: point y ]. + mapping mapProperty: 'y' getter: [ :point | point y ] setter: [ :point :value | point setX: point x setY: value ]. ]; + nextAs: Point ]. + self assert: (reader value: '{"x":1,"y":2}') equals: 1@2. + self assert: (reader value: '{}') equals: Point new +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testPoint2 [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + mapAllInstVarsFor: Point; + nextAs: Point ]. + self assert: (reader value: '{"x":1,"y":2}') equals: 1@2. + self assert: (reader value: '{}') equals: Point new +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testPoint3 [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) + for: Point do: [ :mapping | + mapping mapInstVars: #(x y) ]; + nextAs: Point ]. + self assert: (reader value: '{"x":1,"y":2}') equals: 1@2. + self assert: (reader value: '{}') equals: Point new +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testPointUsingAsString [ + | point | + point := (NeoJSONReader on: '{"x":"1","y":"2"}' readStream) + for: Point + do: [ :mapping | + (mapping + mapProperty: #x + getter: [ :object | object x ] + setter: [ :object :value | object setX: value setY: object y ]) + valueSchema: #AsString. + (mapping + mapProperty: #y + getter: [ :object | object y ] + setter: [ :object :value | object setX: object x setY: value ]) + valueSchema: #AsString ]; + for: #AsString + customDo: [ :mapping | + mapping + encoder: [ :x | x asString ]; + decoder: [ :x | x asNumber ] ]; + nextAs: Point. + self assert: point equals: 1 @ 2 +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testPropertyNamesAsSymbols [ + | json map | + json := '{ "x" : true, "y" : false, "key-1" : 1 }'. + map := (NeoJSONReader on: json readStream) + propertyNamesAsSymbols: true; + next. + self + assert: map + equals: (Dictionary new at: #x put: true; at: #y put: false; at: #'key-1' put: 1; yourself). + self assert: (map keys allSatisfy: [ :each | each isSymbol ]) +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testSmallDictionary [ + | json map smallDictionaryClass | + json := '{ "x" : true, "y" : false, "key-1" : 1 }'. + smallDictionaryClass := Smalltalk at: #SmallDictionary ifAbsent: [ Dictionary ]. + map := (NeoJSONReader on: json readStream) + mapClass: smallDictionaryClass; + next. + self + assert: map + equals: (smallDictionaryClass new at: 'x' put: true; at: 'y' put: false; at: 'key-1' put: 1; yourself). + self + assert: map class + equals: smallDictionaryClass +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testStrings [ + | reader | + reader := [ :string | + (NeoJSONReader on: string readStream) next ]. + self assert: (reader value: '"foo"') equals: 'foo'. + self assert: (reader value: '""') equals: ''. + self assert: (reader value: '"Foo BAR"') equals: 'Foo BAR'. + self assert: (reader value: '" foo "') equals: ' foo '. + self assert: (reader value: '"\u00E9l\u00E8ve en Fran\u00E7ais"') equals: 'élève en Français'. + self + assert: (reader value: '"\"\\\/\t\r\n\f\b"') + equals: (String withAll: ( OrderedCollection new + add: $"; + add: $\; + add: $/; + add: Character tab; + add: Character cr; + add: Character lf; + add: Character newPage; + add: Character backspace; + yourself )). + self should: [ reader value: '"open' ] raise: NeoJSONParseError. + self should: [ reader value: '"\uAA"' ] raise: NeoJSONParseError. + self should: [ reader value: '"\uZZ"' ] raise: NeoJSONParseError. + self should: [ reader value: '"\x"' ] raise: NeoJSONParseError. + self should: [ reader value: ' " ' ] raise: NeoJSONParseError. + +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testSymbol [ + | reader | + reader := [ :input | + (NeoJSONReader on: input readStream) + for: Symbol customDo: [ :mapping | + mapping decoder: [ :string | string asSymbol ] ]; + nextAs: Symbol ]. + self assert: (reader value: ' "foo" ') equals: #foo. + self assert: (reader value: ' "FOO-1" ') equals: #'FOO-1' +] + +{ #category : 'testing' } +NeoJSONReaderTests >> testTime [ + | reader | + reader := [ :input | + (NeoJSONReader on: input readStream) + for: Time customDo: [ :mapping | + mapping decoder: [ :string | Time fromString: string ] ]; + nextAs: Time ]. + self assert: (reader value: ' "14:30:08" ') equals: (Time hour: 14 minute: 30 second: 8) +] diff --git a/repository/Neo-JSON-Tests/NeoJSONTestObject1.class.st b/repository/Neo-JSON-Tests/NeoJSONTestObject1.class.st new file mode 100644 index 0000000..dfd98dc --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONTestObject1.class.st @@ -0,0 +1,133 @@ +" +I am NeoJSONTestObject1. + +I repesent a domain model object. +I have the following properties: + +- id +- name +- timestamp +- points +- bytes + +My JSON representation is like this: + +- id +- name +- created-at +- points +- bytes + +" +Class { + #name : 'NeoJSONTestObject1', + #superclass : 'Object', + #instVars : [ + 'id', + 'name', + 'timestamp', + 'points', + 'bytes' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'instance creation' } +NeoJSONTestObject1 class >> example1 [ + ^ self new + id: 123; + name: 'Example1'; + timestamp: (DateAndTime year: 2012 month: 06 day: 08 hour: 14 minute: 30 second: 15 offset: 1 hour); + points: (Array with: 1@2 with: 3@4); + bytes: #[ 2 4 6 8 ]; + yourself +] + +{ #category : 'accessing' } +NeoJSONTestObject1 class >> neoJsonMapping: mapper [ + mapper for: self do: [ :mapping | + mapping mapInstVars: #(id name). + (mapping mapInstVar: #timestamp to: 'created-at') valueSchema: DateAndTime. + (mapping mapInstVar: #points) valueSchema: #ArrayOfPoints. + (mapping mapInstVar: #bytes) valueSchema: ByteArray ]. + mapper for: DateAndTime customDo: [ :mapping | + mapping decoder: [ :string | DateAndTime fromString: string ]. + mapping encoder: [ :dateAndTime | dateAndTime printString ] ]. + mapper for: #ArrayOfPoints customDo: [ :mapping | + mapping listOfElementSchema: Point ]. + mapper mapAllInstVarsFor: Point. + mapper for: ByteArray customDo: [ :mapping | + mapping listOfType: ByteArray ] +] + +{ #category : 'comparing' } +NeoJSONTestObject1 >> = anObject [ + self == anObject + ifTrue: [ ^ true ]. + self class = anObject class + ifFalse: [ ^ false ]. + ^ id = anObject id + and: [ + name = anObject name + and: [ + timestamp = anObject timestamp + and: [ + points = anObject points + and: [ bytes = anObject bytes ] ] ] ] +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> bytes [ + ^ bytes +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> bytes: byteArray [ + bytes := byteArray +] + +{ #category : 'comparing' } +NeoJSONTestObject1 >> hash [ + ^ id hash bitXor: (name hash bitXor: (timestamp hash bitXor: (points hash bitXor: bytes hash))) +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> id [ + ^ id +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> id: integer [ + id := integer +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> name [ + ^ name +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> name: string [ + name := string +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> points [ + ^ points +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> points: arrayOfPoints [ + points := arrayOfPoints +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> timestamp [ + ^ timestamp +] + +{ #category : 'accessing' } +NeoJSONTestObject1 >> timestamp: dateAndTime [ + timestamp := dateAndTime +] diff --git a/repository/Neo-JSON-Tests/NeoJSONTestObject2.class.st b/repository/Neo-JSON-Tests/NeoJSONTestObject2.class.st new file mode 100644 index 0000000..d52e774 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONTestObject2.class.st @@ -0,0 +1,169 @@ +" +I am NeoJSONTestObject2. + +Instance Variables + data: + height: + id: + width: + +Used for benchmarking and other tests. +" +Class { + #name : 'NeoJSONTestObject2', + #superclass : 'Object', + #instVars : [ + 'id', + 'width', + 'height', + 'data' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONTestObject2 class >> benchmark10k [ + "self benchmark10k" + + self benchmark: 10000 +] + +{ #category : 'testing' } +NeoJSONTestObject2 class >> benchmark10kAsDictionary [ + "self benchmark10kAsDictionary" + + self benchmarkAsDictionary: 10000 +] + +{ #category : 'testing' } +NeoJSONTestObject2 class >> benchmark200k [ + "self benchmark200k" + + self benchmark: 200000 +] + +{ #category : 'testing' } +NeoJSONTestObject2 class >> benchmark: count [ + "self benchmark: 1000" + + | collection json size | + collection := Array new: count withAll: self example1. + size := 2 + (count * (NeoJSONWriter toString: self example1) size) + count - 1. + Transcript + cr; + << ('Serializing {1} objects took ms ' format: (Array with: count) ); + show: [ json := String new: size streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: collection ] ] timeToRun. + Transcript + cr; + << ('Deserializing {1} objects took ms ' format: (Array with: count) ); + show: [ NeoJSONReader fromString: json ] timeToRun. +] + +{ #category : 'testing' } +NeoJSONTestObject2 class >> benchmarkAsDictionary: count [ + "self benchmarkAsDictionary: 1000" + + | collection json size | + collection := Array new: count withAll: self example1 asDictionary. + size := 2 + (count * (NeoJSONWriter toString: self example1 asDictionary) size) + count - 1. + Transcript + cr; + << ('Serializing {1} objects took ms ' format: (Array with: count) ); + show: [ json := String new: size streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: collection ] ] timeToRun. + Transcript + cr; + << ('Deserializing {1} objects took ms ' format: (Array with: count) ); + show: [ NeoJSONReader fromString: json ] timeToRun. +] + +{ #category : 'instance creation' } +NeoJSONTestObject2 class >> example1 [ + ^ self new + id: 13; + width: 250; + height: 110; + data: (String new: 512 withAll: $a); + yourself +] + +{ #category : 'accessing' } +NeoJSONTestObject2 class >> neoJsonMapping: mapper [ + "For inheritance mapping to work, the schema/classname must be self, + but the instance variables have to be enumerated manually per class" + + mapper for: self do: [ :mapping | + mapping mapInstVars: #(id width height data) ] +] + +{ #category : 'comparing' } +NeoJSONTestObject2 >> = anObject [ + self == anObject + ifTrue: [ ^ true ]. + self class = anObject class + ifFalse: [ ^ false ]. + ^ id = anObject id + and: [ + height = anObject height + and: [ + width = anObject width + and: [ + data = anObject data ] ] ] +] + +{ #category : 'converting' } +NeoJSONTestObject2 >> asDictionary [ + ^ Dictionary new + at: #id put: id; + at: #height put: height; + at: #width put: width; + at: #data put: data; + yourself +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> data [ + ^ data +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> data: anObject [ + data := anObject +] + +{ #category : 'comparing' } +NeoJSONTestObject2 >> hash [ + ^ id hash bitXor: (width hash bitXor: (height hash bitXor: data hash)) +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> height [ + ^ height +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> height: anObject [ + height := anObject +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> id [ + ^ id +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> id: anObject [ + id := anObject +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> width [ + ^ width +] + +{ #category : 'accessing' } +NeoJSONTestObject2 >> width: anObject [ + width := anObject +] diff --git a/repository/Neo-JSON-Tests/NeoJSONTestObject3.class.st b/repository/Neo-JSON-Tests/NeoJSONTestObject3.class.st new file mode 100644 index 0000000..b48fa2e --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONTestObject3.class.st @@ -0,0 +1,74 @@ +" +I am NeoJSONTestObject3, a subclass of NeoJSONTestObject2. + +Instance Variables + color: + transparent : + +I am used for inheritance testing. + +" +Class { + #name : 'NeoJSONTestObject3', + #superclass : 'NeoJSONTestObject2', + #instVars : [ + 'color', + 'transparent' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'instance creation' } +NeoJSONTestObject3 class >> example1 [ + ^ super example1 + data: (String new: 8 withAll: $a); + color: 'red'; + transparent: true; + yourself +] + +{ #category : 'accessing' } +NeoJSONTestObject3 class >> neoJsonMapping: mapper [ + "For inheritance mapping to work, the schema/classname must be self, + but the instance variables have to be enumerated manually per class" + + super neoJsonMapping: mapper. + mapper for: self do: [ :mapping | + mapping mapInstVars: #(color transparent) ] +] + +{ #category : 'comparing' } +NeoJSONTestObject3 >> = anObject [ + ^ super = anObject + and: [ color = anObject color + and: [ transparent = anObject transparent ] ] +] + +{ #category : 'converting' } +NeoJSONTestObject3 >> asDictionary [ + ^ super asDictionary + at: #color put: color; + at: #transparent put: transparent; + yourself +] + +{ #category : 'accessing' } +NeoJSONTestObject3 >> color [ + ^ color +] + +{ #category : 'accessing' } +NeoJSONTestObject3 >> color: anObject [ + color := anObject +] + +{ #category : 'accessing' } +NeoJSONTestObject3 >> transparent [ + ^ transparent +] + +{ #category : 'accessing' } +NeoJSONTestObject3 >> transparent: anObject [ + transparent := anObject +] diff --git a/repository/Neo-JSON-Tests/NeoJSONValidation.class.st b/repository/Neo-JSON-Tests/NeoJSONValidation.class.st new file mode 100644 index 0000000..1d3a8c5 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONValidation.class.st @@ -0,0 +1,240 @@ +" +I am NeoJSONValidation, a set of tests to validate NeoJSON against some external rules. + +Both positive & negative tests are includes. +Some of these are implementation choices. + +http://seriot.ch/parsing_json.php +https://github.com/nst/JSONTestSuite +https://github.com/nst/JSONTestSuite.git + test_parsing + test_transform + +https://github.com/miloyip/nativejson-benchmark +https://github.com/miloyip/nativejson-benchmark.git + data/jsonchecker + data/roundtrip + +This can only be run with the correct setup (checkout/config). + + NeoJSONValidation new runNativeJsonBenchmarkRoundTrip. + NeoJSONValidation new runNativeJsonBenchmarkJsonCheckerPasses. + NeoJSONValidation new runNativeJsonBenchmarkJsonCheckerFailures. + + NeoJSONValidation new runJsonTestSuiteTestParsingPasses. + NeoJSONValidation new runJsonTestSuiteTestParsingFailures. + NeoJSONValidation new runJsonTestSuiteTestParsingInfo. + +Logging goes to a file, neo-json-validation.log +" +Class { + #name : 'NeoJSONValidation', + #superclass : 'Object', + #instVars : [ + 'gitDirectory', + 'logStream' + ], + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'private' } +NeoJSONValidation >> closeLog [ + logStream ifNotNil: [ + logStream close. + logStream := nil ]. + ^ self logFile exists + ifTrue: [ self logFile contents ] + ifFalse: [ 'log file is empty' ] +] + +{ #category : 'private' } +NeoJSONValidation >> ensureLog [ + logStream ifNil: [ + logStream := self logFile ensureDelete; writeStream. + logStream setToEnd ] + +] + +{ #category : 'accessing' } +NeoJSONValidation >> gitDirectory [ + ^ gitDirectory ifNil: [ gitDirectory := FileLocator home / #Develop / #git ] +] + +{ #category : 'accessing' } +NeoJSONValidation >> gitDirectory: fileReference [ + gitDirectory := fileReference +] + +{ #category : 'accessing' } +NeoJSONValidation >> jsonTestSuiteDirectory [ + ^ self gitDirectory / #JSONTestSuite +] + +{ #category : 'accessing' } +NeoJSONValidation >> jsonTestSuiteTestParsingDirectory [ + ^ self jsonTestSuiteDirectory / 'test_parsing' +] + +{ #category : 'accessing' } +NeoJSONValidation >> jsonTestSuiteTestParsingFailFiles [ + ^ self jsonTestSuiteTestParsingDirectory childrenMatching: 'n_*.json' +] + +{ #category : 'accessing' } +NeoJSONValidation >> jsonTestSuiteTestParsingInfoFiles [ + ^ self jsonTestSuiteTestParsingDirectory childrenMatching: 'i_*.json' +] + +{ #category : 'accessing' } +NeoJSONValidation >> jsonTestSuiteTestParsingPassFiles [ + ^ self jsonTestSuiteTestParsingDirectory childrenMatching: 'y_*.json' +] + +{ #category : 'accessing' } +NeoJSONValidation >> jsonTestSuiteTestTransformDirectory [ + ^ self jsonTestSuiteDirectory / 'test_transform' +] + +{ #category : 'private' } +NeoJSONValidation >> log: message [ + self ensureLog. + logStream nextPutAll: message; lf; flush + +] + +{ #category : 'private' } +NeoJSONValidation >> logFile [ + ^ 'neo-json-validation.log' asFileReference +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkDataDirectory [ + ^ self nativeJsonBenchmarkDirectory / #data +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkDirectory [ + ^ self gitDirectory / 'nativejson-benchmark' +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkJsonCheckerDirectory [ + ^ self nativeJsonBenchmarkDataDirectory / #jsonchecker +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkJsonCheckerFailFiles [ + ^ self nativeJsonBenchmarkJsonCheckerDirectory childrenMatching: 'fail*.json' +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkJsonCheckerPassFiles [ + ^ self nativeJsonBenchmarkJsonCheckerDirectory childrenMatching: 'pass*.json' +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkRoundTripDirectory [ + ^ self nativeJsonBenchmarkDataDirectory / #roundtrip +] + +{ #category : 'accessing' } +NeoJSONValidation >> nativeJsonBenchmarkRoundTripFiles [ + ^ self nativeJsonBenchmarkRoundTripDirectory children +] + +{ #category : 'running' } +NeoJSONValidation >> runJsonTestSuiteTestParsingFailures [ + ^ self + validateFiles: self jsonTestSuiteTestParsingFailFiles + usingTest: [ :file | + | data success | + success := false. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next; failIfNotAtEnd ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := true ]. + success ] +] + +{ #category : 'running' } +NeoJSONValidation >> runJsonTestSuiteTestParsingInfo [ + ^ self + validateFiles: self jsonTestSuiteTestParsingInfoFiles + usingTest: [ :file | + | data success | + success := true. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := false ]. + success ] +] + +{ #category : 'running' } +NeoJSONValidation >> runJsonTestSuiteTestParsingPasses [ + ^ self + validateFiles: self jsonTestSuiteTestParsingPassFiles + usingTest: [ :file | + | data success | + success := true. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := false ]. + success ] +] + +{ #category : 'running' } +NeoJSONValidation >> runNativeJsonBenchmarkJsonCheckerFailures [ + ^ self + validateFiles: self nativeJsonBenchmarkJsonCheckerFailFiles + usingTest: [ :file | + | data success | + success := false. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next; failIfNotAtEnd ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := true ]. + success ] +] + +{ #category : 'running' } +NeoJSONValidation >> runNativeJsonBenchmarkJsonCheckerPasses [ + ^ self + validateFiles: self nativeJsonBenchmarkJsonCheckerPassFiles + usingTest: [ :file | + | data success | + success := true. + [ data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ] ] + on: NeoJSONParseError + do: [ :exception | self log: exception printString. success := false ]. + success ] +] + +{ #category : 'running' } +NeoJSONValidation >> runNativeJsonBenchmarkRoundTrip [ + ^ self + validateFiles: self nativeJsonBenchmarkRoundTripFiles + usingTest: [ :file | + | data json | + data := file readStreamDo: [ :in | (NeoJSONReader on: in) next ]. + json := NeoJSONWriter toString: data. + json = file contents ] +] + +{ #category : 'private' } +NeoJSONValidation >> validateFiles: files usingTest: block [ + | total succeeded failed | + total := succeeded := failed := 0. + files do: [ :file | + | success | + self log: 'Running ' , file pathString. + self log: ([ file contents contractTo: 64 ] on: Error do: [ :exception | exception printString ]). + success := [ block value: file ] + on: Error + do: [ :exception | self log: ' Errored. ' , exception printString. false ]. + total := total + 1. + success + ifTrue: [ succeeded := succeeded + 1 ] + ifFalse: [ failed := failed + 1 ]. + self log: (success ifTrue: [ ' Succeeded' ] ifFalse: [ ' Failed' ]); log: '' ]. + self log: ('{1} total = {2} succeeded + {3} failed' format: (Array with: total with: succeeded with: failed) ). + ^ self closeLog +] diff --git a/repository/Neo-JSON-Tests/NeoJSONWriteReadAsciiOnlyTests.class.st b/repository/Neo-JSON-Tests/NeoJSONWriteReadAsciiOnlyTests.class.st new file mode 100644 index 0000000..a4e520c --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONWriteReadAsciiOnlyTests.class.st @@ -0,0 +1,17 @@ +" +I am NeoJSONWriteReadAsciiOnlyTests. +" +Class { + #name : 'NeoJSONWriteReadAsciiOnlyTests', + #superclass : 'NeoJSONWriteReadTests', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'private' } +NeoJSONWriteReadAsciiOnlyTests >> writeRead: object [ + | json | + json := String streamContents: [ :stream | + (NeoJSONWriter on: stream) asciiOnly: true; nextPut: object ]. + ^ (NeoJSONReader on: json readStream) next +] diff --git a/repository/Neo-JSON-Tests/NeoJSONWriteReadMockStreamTests.class.st b/repository/Neo-JSON-Tests/NeoJSONWriteReadMockStreamTests.class.st new file mode 100644 index 0000000..70e4d12 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONWriteReadMockStreamTests.class.st @@ -0,0 +1,19 @@ +" +I am NeoJSONWriteReadMockStreamTests. +" +Class { + #name : 'NeoJSONWriteReadMockStreamTests', + #superclass : 'NeoJSONWriteReadTests', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'private' } +NeoJSONWriteReadMockStreamTests >> writeRead: object [ + | json | + json := String streamContents: [ :stream | + (NeoJSONWriter on: (NeoJSONMockStream on: stream)) + prettyPrint: true; + nextPut: object ]. + ^ (NeoJSONReader on: (NeoJSONMockStream on: json readStream)) next +] diff --git a/repository/Neo-JSON-Tests/NeoJSONWriteReadPrettyPrintedTests.class.st b/repository/Neo-JSON-Tests/NeoJSONWriteReadPrettyPrintedTests.class.st new file mode 100644 index 0000000..2a9098c --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONWriteReadPrettyPrintedTests.class.st @@ -0,0 +1,62 @@ +" +I am NeoJSONWriteReadPrettyPrintedTests. +" +Class { + #name : 'NeoJSONWriteReadPrettyPrintedTests', + #superclass : 'NeoJSONWriteReadTests', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONWriteReadPrettyPrintedTests >> testDictionaryOfObject2 [ + | data json reader | + data := Dictionary new. + data + at: 'one' put: NeoJSONTestObject2 example1; + at: 'two' put: NeoJSONTestObject2 example1. + json := NeoJSONWriter toStringPretty: data. + reader := NeoJSONReader on: json readStream. + reader for: #DictionaryOfObject2 customDo: [ :mapping | + mapping mapWithValueSchema: NeoJSONTestObject2 ]. + self + assert: (reader nextAs: #DictionaryOfObject2) + equals: data +] + +{ #category : 'testing' } +NeoJSONWriteReadPrettyPrintedTests >> testObject1 [ + | json | + json := NeoJSONWriter toStringPretty: NeoJSONTestObject1 example1. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject1) + equals: NeoJSONTestObject1 example1 +] + +{ #category : 'testing' } +NeoJSONWriteReadPrettyPrintedTests >> testObject2 [ + | json | + json := NeoJSONWriter toStringPretty: NeoJSONTestObject2 example1. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject2) + equals: NeoJSONTestObject2 example1 +] + +{ #category : 'testing' } +NeoJSONWriteReadPrettyPrintedTests >> testObject3 [ + | json | + json := NeoJSONWriter toStringPretty: NeoJSONTestObject3 example1. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject3) + equals: NeoJSONTestObject3 example1 +] + +{ #category : 'private' } +NeoJSONWriteReadPrettyPrintedTests >> writeRead: object [ + | json | + json := String streamContents: [ :stream | + (NeoJSONWriter on: stream) + prettyPrint: true; + nextPut: object ]. + ^ (NeoJSONReader on: json readStream) next +] diff --git a/repository/Neo-JSON-Tests/NeoJSONWriteReadTests.class.st b/repository/Neo-JSON-Tests/NeoJSONWriteReadTests.class.st new file mode 100644 index 0000000..5d26ccb --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONWriteReadTests.class.st @@ -0,0 +1,122 @@ +" +I am NeoJSONWriteReadTests. +" +Class { + #name : 'NeoJSONWriteReadTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testDictionaryOfObject2 [ + | data json reader | + data := Dictionary new. + data + at: 'one' put: NeoJSONTestObject2 example1; + at: 'two' put: NeoJSONTestObject2 example1. + json := NeoJSONWriter toString: data. + reader := NeoJSONReader on: json readStream. + reader for: #DictionaryOfObject2 customDo: [ :mapping | + mapping mapWithValueSchema: NeoJSONTestObject2 ]. + self + assert: (reader nextAs: #DictionaryOfObject2) + equals: data +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testFloats [ + | objects | + objects := OrderedCollection new add: Float pi; add: 1.0; add: -1.0; add: 0.0; add: 1.5e6; add: -1.5e6; add: 1.5e-6; add: -1.5e-6; yourself. + (self writeRead: objects) + with: objects + do: [ :first :second | self assert: (first closeTo: second) ] +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testIntegers [ + | objects | + objects := Array with: 1 with: -1 with: 0 with: 123467890 with: -1234567890. + self + assert: (self writeRead: objects) + equals: objects +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testLists [ + | objects | + objects := Array with: #(1 2 3) with: #() with: #( 'foo' 'bar'). + self + assert: (self writeRead: objects) + equals: objects +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testMaps [ + | objects | + objects := Array + with: Dictionary new + with: (Dictionary with: 'x' -> 1) + with: (Dictionary newFromPairs: #( 'foo' true 'bar' false 'zero' 0 'null' nil 'string' 'Hello World!' )). + self + assert: (self writeRead: objects) + equals: objects +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testObject1 [ + | json | + json := NeoJSONWriter toString: NeoJSONTestObject1 example1. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject1) + equals: NeoJSONTestObject1 example1 +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testObject2 [ + | json | + json := NeoJSONWriter toString: NeoJSONTestObject2 example1. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject2) + equals: NeoJSONTestObject2 example1 +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testObject3 [ + | json | + json := NeoJSONWriter toString: NeoJSONTestObject3 example1. + self + assert: (NeoJSONReader fromString: json as: NeoJSONTestObject3) + equals: NeoJSONTestObject3 example1 +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testSpecials [ + | objects | + objects := Array with: true with: false with: nil. + self + assert: (self writeRead: objects) + equals: objects +] + +{ #category : 'testing' } +NeoJSONWriteReadTests >> testStrings [ + | objects | + objects := OrderedCollection new + add: 'foo'; add: 'Foo BAR'; add: ''; add: ' \\'''; + add: 'élève en Français'; + add: (Character codePoint: 12354) asString; "HIRAGANA LETTER A" + yourself; + asArray. + self + assert: (self writeRead: objects) + equals: objects +] + +{ #category : 'private' } +NeoJSONWriteReadTests >> writeRead: object [ + | json | + json := String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ]. + ^ (NeoJSONReader on: json readStream) next +] diff --git a/repository/Neo-JSON-Tests/NeoJSONWriterTests.class.st b/repository/Neo-JSON-Tests/NeoJSONWriterTests.class.st new file mode 100644 index 0000000..64fa0b0 --- /dev/null +++ b/repository/Neo-JSON-Tests/NeoJSONWriterTests.class.st @@ -0,0 +1,403 @@ +" +I am NeoJSONWriterTests, a test suite for NeoJSONWriter. +" +Class { + #name : 'NeoJSONWriterTests', + #superclass : 'TestCase', + #category : 'Neo-JSON-Tests', + #package : 'Neo-JSON-Tests' +} + +{ #category : 'testing' } +NeoJSONWriterTests >> testAsciiOnlyStrings [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + asciiOnly: true; + nextPut: object ] ]. + self assert: (writer value: 'élève français') equals: '"\u00E9l\u00E8ve fran\u00E7ais"'. + self assert: (writer value: 'foo') equals: '"foo"'. + self assert: (writer value: 'Foo BAR') equals: '"Foo BAR"'. + self assert: (writer value: '') equals: '""'. + self + assert: (writer value: (String withAll: ( OrderedCollection new + add: $"; + add: $\; + add: $/; + add: Character tab; + add: Character cr; + add: Character lf; + add: Character newPage; + add: Character backspace; + yourself ))) + equals: '"\"\\/\t\r\n\f\b"' + + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testAssociation [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Association do: [ :mapping | + mapping mapAccessors: #(key value) ]; + nextPut: object ] ]. + self assert: (writer value: 'foo' -> 42) equals: '{"key":"foo","value":42}'. + self assert: (writer value: Association new) equals: '{}' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testBooleans [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: true) equals: 'true'. + self assert: (writer value: false) equals: 'false'. +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testByteArray [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: #[1 2 3]) equals: '[1,2,3]'. + self assert: (writer value: #[]) equals: '[]' + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testDate [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Date customDo: [ :mapping | + mapping encoder: [ :date | date yyyymmdd ] ]; + nextPut: object ] ]. + self assert: (writer value: (Date fromString: '2012-06-08')) equals: '"2012-06-08"' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testDateAndTime [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: DateAndTime customDo: [ :mapping | + mapping encoder: [ :dateAndTime | dateAndTime printString ] ]; + nextPut: object ] ]. + self + assert: (writer value: (DateAndTime year: 2012 month: 2 day: 14 hour: 16 minute: 40 second: 18 offset: 1 hour)) + equals: '"2012-02-14T16:40:18+01:00"' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testFloatPrinter [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + floatPrinter: NeoJSONFloatPrinter new; + nextPut: object ] ]. + self assert: (writer value: 123.0) equals: '123'. + self assert: (writer value: -123.0) equals: '-123'. + self assert: (writer value: 0.0) equals: '0'. + self assert: (writer value: 1.50) equals: '1.5'. + self assert: (writer value: -1.25) equals: '-1.25'. + self assert: (writer value: Float pi) equals: '3.14159'. + self assert: (writer value: 9.10938356e-31) equals: '9.10938e-31'. + self assert: (writer value: 5.9724e24) equals: '5.9724e24'. + self assert: (writer value: 1234567890.1234567890) equals: '1.23457e9'. + self assert: (writer value: (1/3) asFloat) equals: '0.33333'. +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testFloats [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: 123.0) equals: '123.0'. + self assert: (writer value: -123.0) equals: '-123.0'. + self assert: (writer value: 0.0) equals: '0.0'. +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testIntegers [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: 123) equals: '123'. + self assert: (writer value: -123) equals: '-123'. + self assert: (writer value: 0) equals: '0'. +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testLists [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: #(1 2 3)) equals: '[1,2,3]'. + self assert: (writer value: #()) equals: '[]'. + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testListsExtra [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + #( OrderedCollection LinkedList ByteArray IntegerArray SortedCollection ) do: [ :each | + Smalltalk at: each ifPresent: [ :collectionClass | + self assert: (writer value: (collectionClass withAll: #(1 2 3))) equals: '[1,2,3]'. + self assert: (writer value: collectionClass new) equals: '[]' ] ] + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testMapKeysMustBeStrings [ + self should: [ NeoJSONWriter toString: { 1->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { true->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { nil->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { #()->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { Dictionary new->#a } asDictionary ] raise: Error. + self should: [ NeoJSONWriter toString: { Float pi->#a } asDictionary ] raise: Error. +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testMaps [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: ((writer value: (Dictionary newFromPairs: #( 'x' 1 'y' 2))) includesSubstring: '"x":1'). + self assert: ((writer value: (Dictionary newFromPairs: #( 'x' 1 'y' 2))) includesSubstring: '"y":2'). + self assert: (writer value: Dictionary new) equals: '{}'. + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testMapsExtra [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: (IdentityDictionary newFromPairs: #( 'x' 1))) equals: '{"x":1}'. + self assert: (writer value: IdentityDictionary new) equals: '{}'. + #( SmallDictionary OrderedDictionary OrderedIdentityDictionary ) do: [ :each | + | dictionaryClass | + dictionaryClass := Smalltalk at: each ifAbsent: [ nil ]. + dictionaryClass ifNotNil: [ + self assert: (writer value: (dictionaryClass new at: 'x' put: 1; at: 'y' put: 2; yourself)) equals: '{"x":1,"y":2}'. + self assert: (writer value: dictionaryClass new) equals: '{}'] ] + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testNextPutStringAsHex [ + | output | + output := String + streamContents: [ :out | + (NeoJSONWriter on: out) + for: #StringAsHex + customDo: [ :mapping | + mapping + encoder: [ :x | x asByteArray hex asUppercase ]; + decoder: [ :x | (ByteArray readHexFrom: x) asString ] ]; + nextPut: 'Foo bar!' as: #StringAsHex ]. + self assert: output equals: '"466F6F2062617221"' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testNonBMPCharacterEncoding [ + "Characters not in the Basic Multilingual Plane are encoded as a UTF-16 surrogate pair" + + | string json | + string := 16r1D11E asCharacter asString. "MUSICAL SYMBOL G CLEF" + json := String streamContents: [ :out | + (NeoJSONWriter on: out) asciiOnly: true; nextPut: string ]. + self assert: json equals: '"\uD834\uDD1E"' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testNull [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: nil) equals: 'null' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPoint [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self should: [ writer value: 1@2 ] raise: NeoJSONMappingNotFound +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPoint1 [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Point do: [ :mapping | + mapping mapProperty: 'x' getter: [ :point | point x ] setter: [ :point :value | point x: value ]. + mapping mapProperty: 'y' getter: [ :point | point y ] setter: [ :point :value | point y: value ]. ]; + nextPut: object ] ]. + self assert: (writer value: 1@2) equals: '{"x":1,"y":2}'. + self assert: (writer value: Point new) equals: '{}' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPoint2 [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + mapAllInstVarsFor: Point; + nextPut: object ] ]. + self assert: (writer value: 1@2) equals: '{"x":1,"y":2}'. + self assert: (writer value: Point new) equals: '{}' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPoint3 [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Point do: [ :mapping | + mapping mapInstVars: #(x y) ]; + nextPut: object ] ]. + self assert: (writer value: 1@2) equals: '{"x":1,"y":2}'. + self assert: (writer value: Point new) equals: '{}' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPointUsingAsString [ + | output | + output := String + streamContents: [ :out | + (NeoJSONWriter on: out) + for: Point + do: [ :mapping | + (mapping + mapProperty: #x + getter: [ :object | object x ] + setter: [ :object :value | object setX: value setY: object y ]) + valueSchema: #AsString. + (mapping + mapProperty: #y + getter: [ :object | object y ] + setter: [ :object :value | object setX: object x setY: value ]) + valueSchema: #AsString ]; + for: #AsString + customDo: [ :mapping | + mapping + encoder: [ :x | x asString ]; + decoder: [ :x | x asNumber ] ]; + nextPut: 1 @ 2 ]. + self assert: output equals: '{"x":"1","y":"2"}' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPointWriteNil [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + writeNil: true; + mapAllInstVarsFor: Point; + nextPut: object ] ]. + self assert: (writer value: 1@2) equals: '{"x":1,"y":2}'. + self assert: (writer value: Point new) equals: '{"x":null,"y":null}' +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testPreservePropertyOrder [ + | writer testObject | + (testObject := NeoJSONTestObject2 new) + id: 123; + width: 100; + height: 50; + data: 'test'. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(id width height data) ]; + nextPut: object ] ]. + self assert: (writer value: testObject) equals: '{"id":123,"width":100,"height":50,"data":"test"}'. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(width height data id) ]; + nextPut: object ] ]. + self assert: (writer value: testObject) equals: '{"width":100,"height":50,"data":"test","id":123}'. + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(data id height width) ]; + nextPut: object ] ]. + self assert: (writer value: testObject) equals: '{"data":"test","id":123,"height":50,"width":100}'. + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testStrings [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: 'foo') equals: '"foo"'. + self assert: (writer value: 'Foo BAR') equals: '"Foo BAR"'. + self assert: (writer value: '') equals: '""'. + self + assert: (writer value: (String withAll: ( OrderedCollection new + add: $"; + add: $\; + add: $/; + add: Character tab; + add: Character cr; + add: Character lf; + add: Character newPage; + add: Character backspace; + yourself ))) + equals: '"\"\\/\t\r\n\f\b"' + + + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testSymbol [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) nextPut: object ] ]. + self assert: (writer value: #foo) equals: '"foo"'. + self assert: (writer value: #'FOO-1') equals: '"FOO-1"' + +] + +{ #category : 'testing' } +NeoJSONWriterTests >> testTime [ + | writer | + writer := [ :object | + String streamContents: [ :stream | + (NeoJSONWriter on: stream) + for: Time customDo: [ :mapping | + mapping encoder: [ :time | time printString ] ]; + nextPut: object ] ]. + self assert: ((writer value: (Time fromSeconds: 52208)) includesSubstring: '2:30:08') +] diff --git a/repository/Neo-JSON-Tests/package.st b/repository/Neo-JSON-Tests/package.st new file mode 100644 index 0000000..3e79cf3 --- /dev/null +++ b/repository/Neo-JSON-Tests/package.st @@ -0,0 +1 @@ +Package { #name : 'Neo-JSON-Tests' } diff --git a/t2f2t/components/Core.ston b/t2f2t/components/Core.ston new file mode 100644 index 0000000..c3a3f03 --- /dev/null +++ b/t2f2t/components/Core.ston @@ -0,0 +1,8 @@ +RwSimpleProjectLoadComponentV2 { + #name : 'Core', + #condition : 'common', + #projectNames : [ ], + #componentNames : [ ], + #packageNames : [ ], + #comment : '' +} \ No newline at end of file diff --git a/t2f2t/filetree.ston b/t2f2t/filetree.ston new file mode 100644 index 0000000..11d88bb --- /dev/null +++ b/t2f2t/filetree.ston @@ -0,0 +1,11 @@ +RwProjectSpecificationV2 { + #specName : 'filetree', + #projectSpecPath : 't2f2t', + #componentsPath : 't2f2t/components', + #packagesPath : 'filetree', + #projectsPath : 't2f2t/projects', + #specsPath : 't2f2t/specs', + #packageFormat : 'filetree', + #packageConvention : 'Monticello', + #comment : '' +} \ No newline at end of file diff --git a/t2f2t/projects/README.md b/t2f2t/projects/README.md new file mode 100644 index 0000000..e69de29 diff --git a/t2f2t/specs/filetree.ston b/t2f2t/specs/filetree.ston new file mode 100644 index 0000000..900f663 --- /dev/null +++ b/t2f2t/specs/filetree.ston @@ -0,0 +1,10 @@ +RwLoadSpecificationV2 { + #specName : 'filetree', + #projectName : 't2f2tMeta', + #diskUrl : 'file:///home/tukan/Libraries/3rdPartyLibraries/neoJSON', + #projectSpecFile : 't2f2t/filetree.ston', + #componentNames : [ + 'Core' + ], + #comment : '' +} \ No newline at end of file diff --git a/t2f2t/specs/tonel.ston b/t2f2t/specs/tonel.ston new file mode 100644 index 0000000..bfa28ff --- /dev/null +++ b/t2f2t/specs/tonel.ston @@ -0,0 +1,10 @@ +RwLoadSpecificationV2 { + #specName : 'tonel', + #projectName : 't2f2tMeta', + #diskUrl : 'file:///home/tukan/Libraries/3rdPartyLibraries/neoJSON', + #projectSpecFile : 't2f2t/tonel.ston', + #componentNames : [ + 'Core' + ], + #comment : '' +} \ No newline at end of file diff --git a/t2f2t/tonel.ston b/t2f2t/tonel.ston new file mode 100644 index 0000000..4ac59d8 --- /dev/null +++ b/t2f2t/tonel.ston @@ -0,0 +1,11 @@ +RwProjectSpecificationV2 { + #specName : 'tonel', + #projectSpecPath : 't2f2t', + #componentsPath : 't2f2t/components', + #packagesPath : 'repository', + #projectsPath : 't2f2t/projects', + #specsPath : 't2f2t/specs', + #packageFormat : 'tonel', + #packageConvention : 'Monticello', + #comment : '' +} \ No newline at end of file