Skip to content

Commit

Permalink
Document JSON option; refs #100 CONTRIB-100
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Sierra committed Nov 30, 2010
1 parent 5380552 commit 82c7d49
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions modules/json/src/main/clojure/clojure/contrib/json.clj
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@
{:write-json write-json-generic})

(defn json-str
"Converts x to a JSON-formatted string."
"Converts x to a JSON-formatted string.
Valid options are:
:escape-unicode false
to turn of \uXXXX escapes of Unicode characters."
[x & options]
(let [{:keys [escape-unicode] :or {escape-unicode true}} options
sw (StringWriter.)
Expand All @@ -312,7 +316,11 @@
(.toString sw)))

(defn print-json
"Write JSON-formatted output to *out*"
"Write JSON-formatted output to *out*.
Valid options are:
:escape-unicode false
to turn off \uXXXX escapes of Unicode characters."
[x & options]
(let [{:keys [escape-unicode] :or {escape-unicode true}} options]
(write-json x *out* escape-unicode)))
Expand Down Expand Up @@ -342,7 +350,11 @@
:else (pprint-json-generic x escape-unicode)))

(defn pprint-json
"Pretty-prints JSON representation of x to *out*"
"Pretty-prints JSON representation of x to *out*.
Valid options are:
:escape-unicode false
to turn off \uXXXX escapes of Unicode characters."
[x & options]
(let [{:keys [escape-unicode] :or {escape-unicode true}} options]
(write x :dispatch #(pprint-json-dispatch % escape-unicode))))

0 comments on commit 82c7d49

Please sign in to comment.