Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 73 lines (59 sloc) 2.213 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
;; 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 (http://opensource.org/licenses/eclipse-1.0.php)
;; 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.

(in-ns 'clojure.data.json)

(defn read-json
  "DEPRECATED; replaced by read-str.

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."
  ([input]
     (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
         String
         (read-str input
                   :key-fn key-fn
                   :eof-error? eof-error?
                   :eof-value eof-value)
         java.io.Reader
         (read input
               :key-fn key-fn
               :eof-error? eof-error?
               :eof-value eof-value)))))

(defn write-json
  "DEPRECATED; replaced by 'write'.

Print object to PrintWriter out as JSON"
  [x out escape-unicode?]
  (write x out :escape-unicode escape-unicode?))

(defn json-str
  "DEPRECATED; replaced by 'write-str'.

Converts x to a JSON-formatted string.

Valid options are:
:escape-unicode false
to turn of \\uXXXX escapes of Unicode characters."
  [x & options]
  (apply write-str x options))

(defn print-json
  "DEPRECATED; replaced by 'write' to *out*.

Write JSON-formatted output to *out*.

Valid options are:
:escape-unicode false
to turn off \\uXXXX escapes of Unicode characters."
  [x & options]
  (apply write x *out* options))

(defn pprint-json
  "DEPRECATED; replaced by 'pprint'.

Pretty-prints JSON representation of x to *out*.

Valid options are:
:escape-unicode false
to turn off \\uXXXX escapes of Unicode characters."
  [x & options]
  (apply pprint x options))
Something went wrong with that request. Please try again.