Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DJSON-13: newline & flush output after pprint

Makes clojure.data.json/pprint behave more like clojure.pprint/pprint,
including the fix for CLJ-987.

clojure.data.json/pprint now flushes the output stream and ensures
that its output ends with a newline. This is a small change in
behavior.
  • Loading branch information...
commit 867d0050289ab501c62730c624e6a5eca5263012 1 parent e6c61b4
@stuartsierra stuartsierra authored
View
5 README.md
@@ -120,8 +120,11 @@ Change Log
----------------------------------------
* Release 0.2.4-SNAPSHOT (current Git `master`)
- * Fix [DJSON-15]: bad syntax in test
+ * Small change in behavior: `clojure.data.json/pprint` now adds a
+ newline after its output just like `clojure.core/pprint`
+ * Fix [DJSON-13]: flush output after pprint
* FIX [DJSON-14]: handle EOF inside character escape
+ * Fix [DJSON-15]: bad syntax in test
* Release 0.2.3 on 2013-Aug-30
* Enhancement [DJSON-9]: option to escape U+2028 and U+2029
* Fix [DJSON-11]: printing unnecessary commas with value-fn
View
3  src/main/clojure/clojure/data/json.clj
@@ -494,7 +494,8 @@
(binding [*escape-unicode* escape-unicode
*escape-slash* escape-slash
*key-fn* key-fn]
- (pprint/write x :dispatch pprint-dispatch))))
+ (pprint/with-pprint-dispatch pprint-dispatch
+ (pprint/pprint x)))))
(load "json_compat_0_1")
View
3  src/test/clojure/clojure/data/json_compat_0_1_test.clj
@@ -218,9 +218,6 @@
(let [x (read-json pass1-string false)]
(is (= x (read-json (with-out-str (pprint-json x)) false)))))
-(deftest can-pretty-print-nonescaped-unicode
- (is (= "\"\u1234\u4567\"" (with-out-str (pprint-json "\u1234\u4567" :escape-unicode false)))))
-
(defn benchmark []
(dotimes [_ 8]
(time
View
4 src/test/clojure/clojure/data/json_test.clj
@@ -272,7 +272,9 @@
(is (= x (json/read-str (with-out-str (json/pprint x)))))))
(deftest pretty-print-nonescaped-unicode
- (is (= "\"\u1234\u4567\"" (with-out-str (json/pprint "\u1234\u4567" :escape-unicode false)))))
+ (is (= "\"\u1234\u4567\"\n"
+ (with-out-str
+ (json/pprint "\u1234\u4567" :escape-unicode false)))))
(defn benchmark []
(dotimes [_ 8]
Please sign in to comment.
Something went wrong with that request. Please try again.