API for json.write
Full namespace name: clojure.contrib.json.write
This library will generate JSON from the following types:
* all primitives (Boolean, Byte, Short, Integer, Long, Float, Double)
* String (actually any CharSequence)
* java.util.Map (including Clojure maps)
* java.util.Collection (including Clojure vectors, lists, and sets)
* Java arrays
You can extend this library to handle new types by adding methods to
This library does NOT attempt to preserve round-trip equality between
JSON and Clojure data types. That is, if you write a JSON string with
this library, then read it back with clojure.contrib.json.read, you
won't necessarily get the exact same data structure. For example,
Clojure sets are written as JSON arrays, which will be read back as
If you want indented output, try the clojure-json library at
This implementation attempts to follow the description of JSON at
<http://json.org/>. Maps become JSON objects, all other collections
become JSON arrays. JSON object keys are always converted to strings.
Within strings, all non-ASCII characters are hexadecimal escaped.
JSON Home Page
Public Variables and Functions
Usage: (json-str x)
Converts x to a JSON-formatted string.
Usage: (print-json x)
Prints x as JSON. Nil becomes JSON null. Keywords become
strings, without the leading colon. Maps become JSON objects, all
other collection types become JSON arrays. Java arrays become JSON
arrays. Unicode characters in strings are escaped as \uXXXX.
Numbers print as with pr.