Skip to content

@stuartsierra /data_json_0_1_compat.clj

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
data.json 0.1.x compatibility shim
;;; data.json 0.1.x compatibility shim
;; Loading this file alongside data.json version 0.2.0 adds
;; definitions which make it compatible with the public API of
;; data.json version 0.1.3.
;; Copyright (c) Stuart Sierra, 2012. All rights reserved. The use and
;; distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (
;; By using this software in any fashion, you are agreeing to be bound
;; by the terms of this license. You must not remove this notice, or
;; any other, from this software.
(require '
(in-ns '
(defn read-json
"Reads one JSON value from input String or Reader.
If keywordize? is true (default), object keys will be converted to
keywords. If eof-error? is true (default), empty input will throw
an EOFException; if false EOF will return eof-value. "
(read-json input true true nil))
([input keywordize?]
(read-json input keywordize? true nil))
([input keywordize? eof-error? eof-value]
(let [key-fn (if keywordize? keyword identity)]
(condp instance? input
(read-str input
:key-fn key-fn
:eof-error? eof-error?
:eof-value eof-value)
(read input
:key-fn key-fn
:eof-error? eof-error?
:eof-value eof-value)))))
(defn write-json [x out escape-unicode?]
(write x *out* :escape-unicode escape-unicode?))
(defn json-str [x & options]
(apply write-str x options))
(defn print-json [x & options]
(apply write x *out* options))
(defn pprint-json [x & options]
(apply pprint x options))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.