From d6945753218818242c844aa13bacee482a5b7232 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Thu, 21 Dec 2023 14:45:51 -0600 Subject: [PATCH 01/25] faster slow-write-string --- README.md | 2 ++ src/main/clojure/clojure/data/json.clj | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e9135d..4671e3b 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,8 @@ Change Log * Add [DJSON-46]: In `read`, add `:extra-data-fn` that can be provided to cause an eof check after value is read * Add [DJSON-54]: In `write`, add custom fallback fn for writing unknown types * Perf [DJSON-61]: Faster string writing when string is "simple" + * Perf: Faster string writing when string is not simple + * Perf: Faster `read-str` * Release [2.4.0] on 2021-Jul-12 * Fix [DJSON-52]: Remove Classloader workaround to support Clojure 1.2.x and below * Fix [DJSON-53]: Move deprecated API functions from compat ns into main ns diff --git a/src/main/clojure/clojure/data/json.clj b/src/main/clojure/clojure/data/json.clj index 22b454b..aacaaba 100644 --- a/src/main/clojure/clojure/data/json.clj +++ b/src/main/clojure/clojure/data/json.clj @@ -562,14 +562,17 @@ shorts)) (defn- slow-write-string [^CharSequence s ^Appendable out options] - (let [decoder codepoint-decoder] + (let [decoder codepoint-decoder + slash (get options :escape-slash) + escape-js-separators (get options :escape-js-separators) + escape-unicode (get options :escape-unicode)] (dotimes [i (.length s)] (let [cp (int (.charAt s i))] (if (< cp 128) (case (aget decoder cp) 0 (.append out (char cp)) 1 (do (.append out (char (codepoint \\))) (.append out (char cp))) - 2 (.append out (if (get options :escape-slash) "\\/" "/")) + 2 (.append out (if slash "\\/" "/")) 3 (.append out "\\b") 4 (.append out "\\f") 5 (.append out "\\n") @@ -577,10 +580,10 @@ 7 (.append out "\\t") 8 (->hex-string out cp)) (codepoint-case cp - :js-separators (if (get options :escape-js-separators) + :js-separators (if escape-js-separators (->hex-string out cp) (.append out (char cp))) - (if (get options :escape-unicode) + (if escape-unicode (->hex-string out cp) ; Hexadecimal-escaped (.append out (char cp))))))))) From 8661733068cc29df83ce9e97f781193577541b5f Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Thu, 21 Dec 2023 17:35:05 -0600 Subject: [PATCH 02/25] DJSON-57 Throw better exception on EOF in object or array reading --- README.md | 2 ++ src/main/clojure/clojure/data/json.clj | 25 +++++++++++++++++++-- src/test/clojure/clojure/data/json_test.clj | 12 ++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4671e3b..9eb7dd5 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ Change Log * Next * Fix [DJSON-50]: `read` can take a PushbackReader for repeated read use case * Fix `write` docstring to add `:indent` option added in [DJSON-18] + * Fix [DJSON-57]: Throw better exception when EOF encountered while reading array or object * Add [DJSON-46]: In `read`, add `:extra-data-fn` that can be provided to cause an eof check after value is read * Add [DJSON-54]: In `write`, add custom fallback fn for writing unknown types * Perf [DJSON-61]: Faster string writing when string is "simple" @@ -246,6 +247,7 @@ Change Log * Source-compatible with clojure.contrib.json, except for the name change. [DJSON-61]: https://clojure.atlassian.net/browse/DJSON-61 +[DJSON-57]: https://clojure.atlassian.net/browse/DJSON-57 [DJSON-54]: https://clojure.atlassian.net/browse/DJSON-54 [DJSON-53]: https://clojure.atlassian.net/browse/DJSON-53 [DJSON-52]: https://clojure.atlassian.net/browse/DJSON-52 diff --git a/src/main/clojure/clojure/data/json.clj b/src/main/clojure/clojure/data/json.clj index aacaaba..e03c579 100644 --- a/src/main/clojure/clojure/data/json.clj +++ b/src/main/clojure/clojure/data/json.clj @@ -325,6 +325,9 @@ (defn invalid-array-exception [] (Exception. "JSON error (invalid array)")) +(defn- eof-array-exception [] + (EOFException. "JSON error (EOF in array)")) + (defn- read-array* [^InternalPBR stream options] ;; Handles all array values after the first. (loop [result (transient [])] @@ -332,6 +335,7 @@ (codepoint-case (int (next-token stream)) \] (persistent! r) \, (recur r) + -1 (throw (eof-array-exception)) (throw (invalid-array-exception)))))) (defn- read-array [^InternalPBR stream options] @@ -342,19 +346,35 @@ (codepoint-case c \] [] \, (throw (invalid-array-exception)) + -1 (throw (eof-array-exception)) (do (.unreadChar stream c) (read-array* stream options))))) +(defn- object-colon-exception [] + (Exception. "JSON error (missing `:` in object)")) + +(defn- eof-object-exception [] + (EOFException. "JSON error (EOF in object)")) + +(defn- invalid-key-exception [c] + (if (= c -1) + (throw (eof-object-exception)) + (throw (Exception. (str "JSON error (non-string key in object), found `" (char c) "`, expected `\"`"))))) + +(comment + (compile 'clojure.data.json) + ) + (defn- read-key [^InternalPBR stream] (let [c (int (next-token stream))] (if (= c (codepoint \")) (let [key (read-quoted-string stream)] (if (= (codepoint \:) (int (next-token stream))) key - (throw (Exception. "JSON error (missing `:` in object)")))) + (throw (object-colon-exception)))) (if (= c (codepoint \})) nil - (throw (Exception. (str "JSON error (non-string key in object), found `" (char c) "`, expected `\"`"))))))) + (invalid-key-exception c))))) (defn- read-object [^InternalPBR stream options] ;; Expects to be called with the head of the stream AFTER the @@ -374,6 +394,7 @@ (codepoint-case (int (next-token stream)) \, (recur r) \} (persistent! r) + -1 (throw (eof-object-exception)) (throw (Exception. "JSON error (missing entry in object)")))) (let [r (persistent! result)] (if (empty? r) diff --git a/src/test/clojure/clojure/data/json_test.clj b/src/test/clojure/clojure/data/json_test.clj index 8eb0354..7a82475 100644 --- a/src/test/clojure/clojure/data/json_test.clj +++ b/src/test/clojure/clojure/data/json_test.clj @@ -407,6 +407,18 @@ (is (thrown? java.io.EOFException (json/read-str "\"\\")))) +(deftest throws-eof-in-arrays + (is (thrown? java.io.EOFException + (json/read-str "[1,"))) + (is (thrown? java.io.EOFException + (json/read-str "[1,2,")))) + +(deftest throws-eof-in-objects + (is (thrown? java.io.EOFException + (json/read-str "{"))) + (is (thrown? java.io.EOFException + (json/read-str "{\"\":1,")))) + (deftest accept-eof (is (= ::eof (json/read-str "" :eof-error? false :eof-value ::eof)))) From 457b88e27d7695b38f8b3d9c737e2efb8f2b476d Mon Sep 17 00:00:00 2001 From: clojure-build Date: Fri, 22 Dec 2023 00:23:35 +0000 Subject: [PATCH 03/25] [maven-release-plugin] prepare release v2.5.0 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3cdaccf..3354bfc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 data.json - 2.4.1-SNAPSHOT + 2.5.0 data.json Generating/parsing JSON from/to Clojure data structures https://github.com/clojure/data.json @@ -26,7 +26,7 @@ scm:git:git@github.com:clojure/data.json scm:git:git@github.com:clojure/data.json git@github.com:clojure/data.json.git - HEAD + v2.5.0 From 2254f09e266c0a1236fe8b56efcd73374650e484 Mon Sep 17 00:00:00 2001 From: clojure-build Date: Fri, 22 Dec 2023 00:23:35 +0000 Subject: [PATCH 04/25] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3354bfc..85e06fa 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 data.json - 2.5.0 + 2.5.1-SNAPSHOT data.json Generating/parsing JSON from/to Clojure data structures https://github.com/clojure/data.json @@ -26,7 +26,7 @@ scm:git:git@github.com:clojure/data.json scm:git:git@github.com:clojure/data.json git@github.com:clojure/data.json.git - v2.5.0 + HEAD From 77762e43992b3da485bb41d130e3b86208cf35c1 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Thu, 21 Dec 2023 22:23:50 -0600 Subject: [PATCH 05/25] update for release --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9eb7dd5..bbe33a0 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,23 @@ Releases and Dependency Information This project follows the version scheme MAJOR.MINOR.PATCH where each component provides some relative indication of the size of the change, but does not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). -Latest stable release is [2.4.0] +Latest stable release is [2.5.0] [CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information: ```clojure -org.clojure/data.json {:mvn/version "2.4.0"} +org.clojure/data.json {:mvn/version "2.5.0"} ``` [Leiningen] dependency information: - [org.clojure/data.json "2.4.0"] + [org.clojure/data.json "2.5.0"] [Maven] dependency information: org.clojure data.json - 2.4.0 + 2.5.0 [Leiningen]: https://leiningen.org/ @@ -150,7 +150,7 @@ Developer Information Change Log ---------------------------------------- -* Next +* Release [2.5.0] on 2023-Dec-21 * Fix [DJSON-50]: `read` can take a PushbackReader for repeated read use case * Fix `write` docstring to add `:indent` option added in [DJSON-18] * Fix [DJSON-57]: Throw better exception when EOF encountered while reading array or object @@ -281,6 +281,7 @@ Change Log [DJSON-7]: https://clojure.atlassian.net/browse/DJSON-7 [DJSON-1]: https://clojure.atlassian.net/browse/DJSON-1 +[2.4.0]: https://github.com/clojure/data.json/tree/data.json-2.5.0 [2.4.0]: https://github.com/clojure/data.json/tree/data.json-2.4.0 [2.3.1]: https://github.com/clojure/data.json/tree/data.json-2.3.1 [2.3.0]: https://github.com/clojure/data.json/tree/data.json-2.3.0 From e9e57296e12750512788b723e49ba7f9abb323f9 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Mon, 19 Feb 2024 13:05:58 -0600 Subject: [PATCH 06/25] update parent pom --- pom.xml | 4 ++-- project.clj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 85e06fa..774571c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.clojure pom.contrib - 1.1.0 + 1.2.0 @@ -37,7 +37,7 @@ org.clojure test.check - 1.1.0 + 1.1.1 test diff --git a/project.clj b/project.clj index b367048..825557b 100644 --- a/project.clj +++ b/project.clj @@ -7,7 +7,7 @@ :test-paths ["src/test/clojure" "src/test/clojure-perf"] :profiles {:dev {:dependencies [[com.clojure-goes-fast/clj-async-profiler "0.5.0"] [com.clojure-goes-fast/clj-java-decompiler "0.3.0"] - [org.clojure/test.check "1.1.0"] + [org.clojure/test.check "1.1.1"] [criterium/criterium "0.4.6"] [metosin/jsonista "0.3.1"] [cheshire/cheshire "5.10.0"] From 3859eaea8a0bff83d3ebeb96e3462a48965a804e Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 4 Jun 2024 11:22:24 -0500 Subject: [PATCH 07/25] Add missing readme links --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbe33a0..9372cbe 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,7 @@ Change Log [DJSON-50]: https://clojure.atlassian.net/browse/DJSON-50 [DJSON-48]: https://clojure.atlassian.net/browse/DJSON-48 [DJSON-47]: https://clojure.atlassian.net/browse/DJSON-47 +[DJSON-46]: https://clojure.atlassian.net/browse/DJSON-46 [DJSON-45]: https://clojure.atlassian.net/browse/DJSON-45 [DJSON-43]: https://clojure.atlassian.net/browse/DJSON-43 [DJSON-41]: https://clojure.atlassian.net/browse/DJSON-41 @@ -281,7 +282,7 @@ Change Log [DJSON-7]: https://clojure.atlassian.net/browse/DJSON-7 [DJSON-1]: https://clojure.atlassian.net/browse/DJSON-1 -[2.4.0]: https://github.com/clojure/data.json/tree/data.json-2.5.0 +[2.5.0]: https://github.com/clojure/data.json/tree/data.json-2.5.0 [2.4.0]: https://github.com/clojure/data.json/tree/data.json-2.4.0 [2.3.1]: https://github.com/clojure/data.json/tree/data.json-2.3.1 [2.3.0]: https://github.com/clojure/data.json/tree/data.json-2.3.0 From 9af6f1870356f050866e8591ee312a5da14f0345 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 12:30:53 -0600 Subject: [PATCH 08/25] add buffer size constraint in read docstring --- src/main/clojure/clojure/data/json.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/clojure/clojure/data/json.clj b/src/main/clojure/clojure/data/json.clj index e03c579..76a3e53 100644 --- a/src/main/clojure/clojure/data/json.clj +++ b/src/main/clojure/clojure/data/json.clj @@ -483,7 +483,8 @@ "Reads a single item of JSON data from a java.io.Reader. If you wish to repeatedly read items from the same reader, you must - supply a PushbackReader and reuse it on subsequent calls. + supply a PushbackReader with buffer size >= 64, and reuse it on + subsequent calls. Options are key-value pairs, valid options are: From 101354d9dc1fb7dd05d9737d329ac19829c8367c Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 12:40:40 -0600 Subject: [PATCH 09/25] update changelog --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9372cbe..a4e8901 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,8 @@ Developer Information Change Log ---------------------------------------- +* next + * In `read`, update docstring to specify minimum buffer size if PushbackReader supplied * Release [2.5.0] on 2023-Dec-21 * Fix [DJSON-50]: `read` can take a PushbackReader for repeated read use case * Fix `write` docstring to add `:indent` option added in [DJSON-18] From dbff2f72118caba7f2c660a125cb81066692978c Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 12:40:58 -0600 Subject: [PATCH 10/25] remove duplication in tests --- src/test/clojure/clojure/data/json_test.clj | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/test/clojure/clojure/data/json_test.clj b/src/test/clojure/clojure/data/json_test.clj index 7a82475..2f78fcd 100644 --- a/src/test/clojure/clojure/data/json_test.clj +++ b/src/test/clojure/clojure/data/json_test.clj @@ -3,21 +3,27 @@ [clojure.test :refer :all] [clojure.string :as str])) +(defn pbr + ([s] + (pbr s 64)) + ([s size] + (if (< size 64) + (throw (RuntimeException. "Size must be >= 64")) + (java.io.PushbackReader. (java.io.StringReader. s) size)))) + (deftest read-from-pushback-reader - (let [s (java.io.PushbackReader. (java.io.StringReader. "42"))] - (is (= 42 (json/read s))))) + (is (= 42 (json/read (pbr "42")))) + (is (= ["abc" "def"] (json/read (pbr "[\"abc\", \"def\"]"))))) -;; DJSON-50 - pass PBR to safely do reapeated read +;; DJSON-50 - pass PBR to safely do repeated read (deftest read-multiple (let [st "{\"foo\":\"some string\"}{\"foo\":\"another string\"}" - srdr (java.io.StringReader. st) - pbr (java.io.PushbackReader. srdr 64)] + pbr (pbr st)] (is (= {"foo" "some string"} (json/read pbr))) (is (= {"foo" "another string"} (json/read pbr)))) (let [st "{\"foo\":\"some string\"}{\"foo\":\"another long ......................................................... string\"}" - srdr (java.io.StringReader. st) - pbr (java.io.PushbackReader. srdr 64)] + pbr (pbr st)] (is (= {"foo" "some string"} (json/read pbr))) (is (= {"foo" "another long ......................................................... string"} (json/read pbr))))) From 45798a206304aa16b5f78e871fbe1d9d9b31732f Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 13:22:41 -0600 Subject: [PATCH 11/25] Fix read of number followed by EOF can break subsequent read from seeing EOF --- README.md | 3 ++- src/main/clojure/clojure/data/json.clj | 18 ++++++++++++++---- src/test/clojure/clojure/data/json_test.clj | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a4e8901..0cd9fde 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,8 @@ Change Log ---------------------------------------- * next - * In `read`, update docstring to specify minimum buffer size if PushbackReader supplied + * Fix: `read` of number followed by EOF can break subsequent read from seeing EOF + * In `read`, update docstring to specify minimum buffer size when PushbackReader supplied * Release [2.5.0] on 2023-Dec-21 * Fix [DJSON-50]: `read` can take a PushbackReader for repeated read use case * Fix `write` docstring to add `:indent` option added in [DJSON-18] diff --git a/src/main/clojure/clojure/data/json.clj b/src/main/clojure/clojure/data/json.clj index 76a3e53..2eb1588 100644 --- a/src/main/clojure/clojure/data/json.clj +++ b/src/main/clojure/clojure/data/json.clj @@ -33,6 +33,7 @@ (readChars [_ buffer start bufflen] (.read rdr ^chars buffer start bufflen)) (unreadChar [_ c] + ;; ASSERT: c should never be -1 (EOF) (.unread rdr c)) (unreadChars [_ buffer start bufflen] (.unread rdr buffer start bufflen)) @@ -63,6 +64,7 @@ (.getChars ^String s p end ^chars buffer start))) (if (pos? n) n -1))) (unreadChar [_ _c] + ;; ASSERT: c should never be -1 (EOF) (set! pos (unchecked-dec pos)) nil) (unreadChars [_ _buffer _start bufflen] @@ -234,9 +236,11 @@ :whitespace (do (.unreadChar stream c) false) - (\, \] \} -1) + (\, \] \}) (do (.unreadChar stream c) false) + -1 + false (throw (Exception. "JSON error (invalid number literal)"))) ;; previous character is a "0" :frac-point @@ -251,9 +255,11 @@ :whitespace (do (.unreadChar stream c) false) - (\, \] \} -1) + (\, \] \}) (do (.unreadChar stream c) false) + -1 + false ;; Disallow zero-padded numbers or invalid characters (throw (Exception. "JSON error (invalid number literal)"))) ;; previous character is a "." @@ -276,9 +282,11 @@ :whitespace (do (.unreadChar stream c) true) - (\, \] \} -1) + (\, \] \}) (do (.unreadChar stream c) true) + -1 + true (throw (Exception. "JSON error (invalid number literal)"))) ;; previous character is a "e" or "E" :exp-symbol @@ -306,9 +314,11 @@ :whitespace (do (.unreadChar stream c) true) - (\, \] \} -1) + (\, \] \}) (do (.unreadChar stream c) true) + -1 + true (throw (Exception. "JSON error (invalid number literal)"))))))] (if decimal? (read-decimal (str buffer) bigdec?) diff --git a/src/test/clojure/clojure/data/json_test.clj b/src/test/clojure/clojure/data/json_test.clj index 2f78fcd..aa6d79c 100644 --- a/src/test/clojure/clojure/data/json_test.clj +++ b/src/test/clojure/clojure/data/json_test.clj @@ -27,6 +27,24 @@ (is (= {"foo" "some string"} (json/read pbr))) (is (= {"foo" "another long ......................................................... string"} (json/read pbr))))) +(defn read-then-eof [s] + (let [r (pbr s) + val (json/read r :eof-error? false :eof-value :EOF)] + (is (= :EOF (json/read r :eof-error? false :eof-value :EOF))) + val)) + +(deftest read-multiple-eof + (are [expected s] (= expected (read-then-eof s)) + 1.2 "1.2" + 0 "0" + 1 "1" + 1.0 "1.0" + "abc" "\"abc\"" + "\u2202" "\"\u2202\"" + [] "[]" + [1 2] "[1, 2]") + ) + (deftest read-from-reader (let [s (java.io.StringReader. "42")] (is (= 42 (json/read s))))) From b5a5898fe49c0412732a5784cd01a60b1e7f29ca Mon Sep 17 00:00:00 2001 From: clojure-build Date: Tue, 26 Nov 2024 19:27:17 +0000 Subject: [PATCH 12/25] [maven-release-plugin] prepare release v2.5.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 774571c..201c6cc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 data.json - 2.5.1-SNAPSHOT + 2.5.1 data.json Generating/parsing JSON from/to Clojure data structures https://github.com/clojure/data.json @@ -26,7 +26,7 @@ scm:git:git@github.com:clojure/data.json scm:git:git@github.com:clojure/data.json git@github.com:clojure/data.json.git - HEAD + v2.5.1 From d9309fba2f89c2e259905229d7f40c3bf49ad27d Mon Sep 17 00:00:00 2001 From: clojure-build Date: Tue, 26 Nov 2024 19:27:17 +0000 Subject: [PATCH 13/25] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 201c6cc..f02b512 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 data.json - 2.5.1 + 2.5.2-SNAPSHOT data.json Generating/parsing JSON from/to Clojure data structures https://github.com/clojure/data.json @@ -26,7 +26,7 @@ scm:git:git@github.com:clojure/data.json scm:git:git@github.com:clojure/data.json git@github.com:clojure/data.json.git - v2.5.1 + HEAD From 300886647b53bea76c5ea097f9322656ee4ba4b9 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 13:34:30 -0600 Subject: [PATCH 14/25] update for release --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0cd9fde..889fe37 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,23 @@ Releases and Dependency Information This project follows the version scheme MAJOR.MINOR.PATCH where each component provides some relative indication of the size of the change, but does not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). -Latest stable release is [2.5.0] +Latest stable release is [2.5.1] [CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information: ```clojure -org.clojure/data.json {:mvn/version "2.5.0"} +org.clojure/data.json {:mvn/version "2.5.1"} ``` [Leiningen] dependency information: - [org.clojure/data.json "2.5.0"] + [org.clojure/data.json "2.5.1"] [Maven] dependency information: org.clojure data.json - 2.5.0 + 2.5.1 [Leiningen]: https://leiningen.org/ @@ -150,7 +150,7 @@ Developer Information Change Log ---------------------------------------- -* next +* Release [2.5.1] on 2024-Nov-26 * Fix: `read` of number followed by EOF can break subsequent read from seeing EOF * In `read`, update docstring to specify minimum buffer size when PushbackReader supplied * Release [2.5.0] on 2023-Dec-21 @@ -285,6 +285,7 @@ Change Log [DJSON-7]: https://clojure.atlassian.net/browse/DJSON-7 [DJSON-1]: https://clojure.atlassian.net/browse/DJSON-1 +[2.5.1]: https://github.com/clojure/data.json/tree/data.json-2.5.1 [2.5.0]: https://github.com/clojure/data.json/tree/data.json-2.5.0 [2.4.0]: https://github.com/clojure/data.json/tree/data.json-2.4.0 [2.3.1]: https://github.com/clojure/data.json/tree/data.json-2.3.1 From 711b9cdb81fd6677122a53e30aa3660c9eef656a Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 13:37:30 -0600 Subject: [PATCH 15/25] update changelog --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 889fe37..2a849da 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,8 @@ Change Log ---------------------------------------- * Release [2.5.1] on 2024-Nov-26 - * Fix: `read` of number followed by EOF can break subsequent read from seeing EOF - * In `read`, update docstring to specify minimum buffer size when PushbackReader supplied + * Fix: `read` of JSON number followed by EOF can break subsequent read on supplier PBR from seeing EOF + * Fix: `read` docstring updated to specify minimum buffer size when PushbackReader supplied (64) * Release [2.5.0] on 2023-Dec-21 * Fix [DJSON-50]: `read` can take a PushbackReader for repeated read use case * Fix `write` docstring to add `:indent` option added in [DJSON-18] From 7d5e30d731e279dfcb2e9867c9373060aaa9c6a1 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 26 Nov 2024 13:38:42 -0600 Subject: [PATCH 16/25] fix markdown tag links --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2a849da..3503642 100644 --- a/README.md +++ b/README.md @@ -285,16 +285,16 @@ Change Log [DJSON-7]: https://clojure.atlassian.net/browse/DJSON-7 [DJSON-1]: https://clojure.atlassian.net/browse/DJSON-1 -[2.5.1]: https://github.com/clojure/data.json/tree/data.json-2.5.1 -[2.5.0]: https://github.com/clojure/data.json/tree/data.json-2.5.0 -[2.4.0]: https://github.com/clojure/data.json/tree/data.json-2.4.0 -[2.3.1]: https://github.com/clojure/data.json/tree/data.json-2.3.1 -[2.3.0]: https://github.com/clojure/data.json/tree/data.json-2.3.0 -[2.2.3]: https://github.com/clojure/data.json/tree/data.json-2.2.3 -[2.2.2]: https://github.com/clojure/data.json/tree/data.json-2.2.2 -[2.2.1]: https://github.com/clojure/data.json/tree/data.json-2.2.1 -[2.2.0]: https://github.com/clojure/data.json/tree/data.json-2.2.0 -[2.1.1]: https://github.com/clojure/data.json/tree/data.json-2.1.1 +[2.5.1]: https://github.com/clojure/data.json/tree/v2.5.1 +[2.5.0]: https://github.com/clojure/data.json/tree/v2.5.0 +[2.4.0]: https://github.com/clojure/data.json/tree/v2.4.0 +[2.3.1]: https://github.com/clojure/data.json/tree/v2.3.1 +[2.3.0]: https://github.com/clojure/data.json/tree/v2.3.0 +[2.2.3]: https://github.com/clojure/data.json/tree/v2.2.3 +[2.2.2]: https://github.com/clojure/data.json/tree/v2.2.2 +[2.2.1]: https://github.com/clojure/data.json/tree/v2.2.1 +[2.2.0]: https://github.com/clojure/data.json/tree/v2.2.0 +[2.1.1]: https://github.com/clojure/data.json/tree/v2.1.1 [2.1.0]: https://github.com/clojure/data.json/tree/data.json-2.1.0 [2.0.2]: https://github.com/clojure/data.json/tree/data.json-2.0.2 [2.0.1]: https://github.com/clojure/data.json/tree/data.json-2.0.1 From 60dde602ee7d435d238c8d077c0424084e519db9 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Wed, 27 Nov 2024 13:05:29 -0600 Subject: [PATCH 17/25] update deps in benchmark test --- project.clj | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/project.clj b/project.clj index 825557b..20eb8ba 100644 --- a/project.clj +++ b/project.clj @@ -1,20 +1,19 @@ ;; NOTE: Used only for perf testing - this project is built with Maven (see pom.xml) (defproject clojure.data.json "1.1.1-SNAPSHOT" - :dependencies [[org.clojure/clojure "1.10.3"]] + :dependencies [[org.clojure/clojure "1.12.0"]] :source-paths ["src/main/clojure"] :java-source-paths ["src/main/java"] :java-test-paths ["src/test/java"] :test-paths ["src/test/clojure" "src/test/clojure-perf"] - :profiles {:dev {:dependencies [[com.clojure-goes-fast/clj-async-profiler "0.5.0"] - [com.clojure-goes-fast/clj-java-decompiler "0.3.0"] + :profiles {:dev {:dependencies [[com.clojure-goes-fast/clj-async-profiler "1.5.1"] + [com.clojure-goes-fast/clj-java-decompiler "0.3.6"] [org.clojure/test.check "1.1.1"] [criterium/criterium "0.4.6"] - [metosin/jsonista "0.3.1"] - [cheshire/cheshire "5.10.0"] - [org.openjdk.jmh/jmh-core "1.28"] - [jmh-clojure "0.4.0"] + [metosin/jsonista "0.3.12"] + [cheshire/cheshire "5.13.0"] + [org.openjdk.jmh/jmh-core "1.37"] + [jmh-clojure "0.4.1"] [com.jsoniter/jsoniter "0.9.23"]] :resource-paths ["dev-resources"] :global-vars {*warn-on-reflection* true}}} - ;;:plugins [[lein-nodisassemble "0.1.3"]] :jvm-opts ["-Djdk.attach.allowAttachSelf=true"]) From 09d6fafb09462ab4c7f9a46e6a478f893907e529 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Wed, 27 Nov 2024 14:32:21 -0600 Subject: [PATCH 18/25] DJSON-56 - in nextToken let invalid char < 32 flow out to specific parsers for better errors --- README.md | 3 +++ src/main/clojure/clojure/data/json.clj | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3503642..fe17344 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,8 @@ Developer Information Change Log ---------------------------------------- +* Next + * Fix: [DJSON-56] During `read`, better error messages for chars < 32 * Release [2.5.1] on 2024-Nov-26 * Fix: `read` of JSON number followed by EOF can break subsequent read on supplier PBR from seeing EOF * Fix: `read` docstring updated to specify minimum buffer size when PushbackReader supplied (64) @@ -251,6 +253,7 @@ Change Log [DJSON-61]: https://clojure.atlassian.net/browse/DJSON-61 [DJSON-57]: https://clojure.atlassian.net/browse/DJSON-57 +[DJSON-56]: https://clojure.atlassian.net/browse/DJSON-56 [DJSON-54]: https://clojure.atlassian.net/browse/DJSON-54 [DJSON-53]: https://clojure.atlassian.net/browse/DJSON-53 [DJSON-52]: https://clojure.atlassian.net/browse/DJSON-52 diff --git a/src/main/clojure/clojure/data/json.clj b/src/main/clojure/clojure/data/json.clj index 2eb1588..8afcd14 100644 --- a/src/main/clojure/clojure/data/json.clj +++ b/src/main/clojure/clojure/data/json.clj @@ -330,7 +330,7 @@ (int c) (codepoint-case (int c) :whitespace (recur (.readChar stream)) - -1 -1)))) + c)))) (defn invalid-array-exception [] (Exception. "JSON error (invalid array)")) From f3cc3bda6b6d9bdcde0034e60ba4ebcc3aefeed0 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Fri, 30 May 2025 15:03:23 -0500 Subject: [PATCH 19/25] update to new parent pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f02b512..8e95317 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.clojure pom.contrib - 1.2.0 + 1.3.0 From 369efc56ab5f3f59955d2cc38bb437161a6da8f9 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Fri, 24 Oct 2025 13:25:15 -0500 Subject: [PATCH 20/25] Update README.md Add breaking change note in the changelog for 2.0.0 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fe17344..6ff34a6 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,7 @@ Change Log * Perf [DJSON-35]: Replace PrintWriter with more generic Appendable, reduce wrapping * Perf [DJSON-34]: More efficient writing for common path * Perf [DJSON-32]: Use option map instead of dynamic variables (affects read+write) + * NOTE: Includes a breaking change in the internal JSONWriter protocol method signature * Perf [DJSON-33]: Improve speed of reading JSON strings * Fix [DJSON-30]: Fix bad test * Release [1.1.0] on 2021-Mar-5 From 3d41c3af5d4d2b5e9acaf68945c44c202c3d609e Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Fri, 2 Jan 2026 08:33:39 -0600 Subject: [PATCH 21/25] update permissions in workflows --- .github/workflows/doc-build.yml | 3 +++ .github/workflows/release.yml | 3 +++ .github/workflows/snapshot.yml | 3 +++ .github/workflows/test.yml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index e379e5d..07265e0 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -1,5 +1,8 @@ name: Build API Docs +permissions: + contents: write + on: workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2718bd..286cf95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,8 @@ name: Release on demand +permissions: + contents: write + on: workflow_dispatch: inputs: diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 2472957..9fdad8c 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -1,5 +1,8 @@ name: Snapshot on demand +permissions: + contents: read + on: [workflow_dispatch] jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1fa127c..2cc441a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,8 @@ name: Test +permissions: + contents: read + on: [push] jobs: From 12574f110ef7ac4591ca64c71a4bfcc144b3f7e7 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Fri, 2 Jan 2026 08:39:52 -0600 Subject: [PATCH 22/25] update to latest parent pom --- README.md | 12 +++++++----- deps.edn | 2 +- pom.xml | 10 +++++----- project.clj | 12 ++++++------ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6ff34a6..653f3e2 100644 --- a/README.md +++ b/README.md @@ -13,23 +13,23 @@ Releases and Dependency Information This project follows the version scheme MAJOR.MINOR.PATCH where each component provides some relative indication of the size of the change, but does not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). -Latest stable release is [2.5.1] +Latest stable release is [2.5.2] [CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information: ```clojure -org.clojure/data.json {:mvn/version "2.5.1"} +org.clojure/data.json {:mvn/version "2.5.2"} ``` [Leiningen] dependency information: - [org.clojure/data.json "2.5.1"] + [org.clojure/data.json "2.5.2"] [Maven] dependency information: org.clojure data.json - 2.5.1 + 2.5.2 [Leiningen]: https://leiningen.org/ @@ -150,7 +150,8 @@ Developer Information Change Log ---------------------------------------- -* Next +* Release [2.5.2] on 2026-Jan-02 + * Update to latest parent pom and Clojure 1.11.4 * Fix: [DJSON-56] During `read`, better error messages for chars < 32 * Release [2.5.1] on 2024-Nov-26 * Fix: `read` of JSON number followed by EOF can break subsequent read on supplier PBR from seeing EOF @@ -289,6 +290,7 @@ Change Log [DJSON-7]: https://clojure.atlassian.net/browse/DJSON-7 [DJSON-1]: https://clojure.atlassian.net/browse/DJSON-1 +[2.5.2]: https://github.com/clojure/data.json/tree/v2.5.2 [2.5.1]: https://github.com/clojure/data.json/tree/v2.5.1 [2.5.0]: https://github.com/clojure/data.json/tree/v2.5.0 [2.4.0]: https://github.com/clojure/data.json/tree/v2.4.0 diff --git a/deps.edn b/deps.edn index eff4f54..1fafc86 100644 --- a/deps.edn +++ b/deps.edn @@ -1,2 +1,2 @@ {:paths ["src/main/clojure"] - :deps {org.clojure/clojure {:mvn/version "1.9.0"}}} + :deps {org.clojure/clojure {:mvn/version "1.11.4"}}} diff --git a/pom.xml b/pom.xml index 8e95317..991ac1d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.clojure pom.contrib - 1.3.0 + 1.4.0 @@ -30,14 +30,14 @@ - 1.9.0 + 1.11.4 org.clojure test.check - 1.1.1 + 1.1.3 test @@ -71,7 +71,7 @@ maven-jar-plugin - 3.0.2 + 3.5.0 default-jar @@ -89,7 +89,7 @@ maven-assembly-plugin - 3.0.0 + 3.8.0 aot-jar diff --git a/project.clj b/project.clj index 20eb8ba..17f63e4 100644 --- a/project.clj +++ b/project.clj @@ -1,16 +1,16 @@ ;; NOTE: Used only for perf testing - this project is built with Maven (see pom.xml) (defproject clojure.data.json "1.1.1-SNAPSHOT" - :dependencies [[org.clojure/clojure "1.12.0"]] + :dependencies [[org.clojure/clojure "1.12.4"]] :source-paths ["src/main/clojure"] :java-source-paths ["src/main/java"] :java-test-paths ["src/test/java"] :test-paths ["src/test/clojure" "src/test/clojure-perf"] - :profiles {:dev {:dependencies [[com.clojure-goes-fast/clj-async-profiler "1.5.1"] - [com.clojure-goes-fast/clj-java-decompiler "0.3.6"] - [org.clojure/test.check "1.1.1"] + :profiles {:dev {:dependencies [[com.clojure-goes-fast/clj-async-profiler "1.6.2"] + [com.clojure-goes-fast/clj-java-decompiler "0.3.7"] + [org.clojure/test.check "1.1.3"] [criterium/criterium "0.4.6"] - [metosin/jsonista "0.3.12"] - [cheshire/cheshire "5.13.0"] + [metosin/jsonista "0.3.13"] + [cheshire/cheshire "6.1.0"] [org.openjdk.jmh/jmh-core "1.37"] [jmh-clojure "0.4.1"] [com.jsoniter/jsoniter "0.9.23"]] From 0421f0098608e8b4cc6c23802dcfa22389278f1d Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Fri, 2 Jan 2026 08:46:17 -0600 Subject: [PATCH 23/25] make empty javadoc jar --- pom.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pom.xml b/pom.xml index 991ac1d..187b814 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,19 @@ + + javadoc-jar + package + + jar + + + javadoc + + **/*.html + + + From 1fce9070ee851f49a6c4ce6e1c0bb0db4d7594a0 Mon Sep 17 00:00:00 2001 From: clojure-build Date: Fri, 2 Jan 2026 14:47:36 +0000 Subject: [PATCH 24/25] [maven-release-plugin] prepare release v2.5.2 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 187b814..130cac9 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 data.json - 2.5.2-SNAPSHOT + 2.5.2 data.json Generating/parsing JSON from/to Clojure data structures https://github.com/clojure/data.json @@ -26,7 +26,7 @@ scm:git:git@github.com:clojure/data.json scm:git:git@github.com:clojure/data.json git@github.com:clojure/data.json.git - HEAD + v2.5.2 From 94463ffb54482427fd9b31f264b06bff6dcfd557 Mon Sep 17 00:00:00 2001 From: clojure-build Date: Fri, 2 Jan 2026 14:47:36 +0000 Subject: [PATCH 25/25] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 130cac9..7af80aa 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 data.json - 2.5.2 + 2.5.3-SNAPSHOT data.json Generating/parsing JSON from/to Clojure data structures https://github.com/clojure/data.json @@ -26,7 +26,7 @@ scm:git:git@github.com:clojure/data.json scm:git:git@github.com:clojure/data.json git@github.com:clojure/data.json.git - v2.5.2 + HEAD