Welcome! Please see the About page for a little more info on how this works.

0 votes
in data.json by

Handling of numeric literals doesn't perform according to the JSON spec.

Example:

(require '[clojure.data.json :as json]) (json/read-str "123abc")

Returns the number 1232. According to the spec, this should actually be an invalid literal and throw an exception:

!http://json.org/number.gif!

2 Answers

0 votes
by

Comment made by: alex+import

(I assume there's a typo in the description - 123 is returned, not 1232)

It's not just literal values, non-whitespace at the end of any input is silently ignored and should be rejected:

(json/read-str "{}xxx") => {} (json/read-str "[]yyy") => [] (json/read-str "\"\"zzz") => ""

NB This behaviour agrees with the docstring ("Reads a single item of JSON data from ...").

0 votes
by
Reference: https://clojure.atlassian.net/browse/DJSON-21 (reported by alex+import)
...