• (json-str x)
Converts x to a JSON-formatted string.

2 Examples top

  • (json-str {:a "a value"})
    "{\"a\":\"a value\"}"
    
    (json-str {[1 2] [1,2,3]})
    "{\"[1 2]\":[1,2,3]}"
    
  • (json-str 1)  
    "1"
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/json.clj:301 top

(defn json-str
  "Converts x to a JSON-formatted string."
  [x]
  (let [sw (StringWriter.)
        out (PrintWriter. sw)]
    (write-json x out)
    (.toString sw)))
Vars in clojure.contrib.json/json-str: defn let
Used in 0 other vars

Comments top

No comments for json-str. Log in to add a comment.