 (ns cheshire.core
-  (:use [cheshire.factory]
-        [cheshire.generate :only [generate]]
-        [cheshire.parse :only [parse]])
+  "Main encoding and decoding namespace."
+  (:require [cheshire.factory :as factory]
+            [cheshire.generate :as gen]
+            [cheshire.parse :as parse])
   (:import (com.fasterxml.jackson.core JsonParser JsonFactory
                                        JsonGenerator$Feature)
            (com.fasterxml.jackson.dataformat.smile SmileFactory)

  ([obj opt-map]
     (let [baos (ByteArrayOutputStream.)
           generator (.createJsonGenerator ^SmileFactory
                                           (or *smile-factory* smile-factory)
                                           baos)]
       (generate generator obj (or (:date-format opt-map) default-date-format)
                 (:ex opt-map))
       (.flush generator)
       (.toByteArray baos))))

  "Internal lazy-seq parser"
  [^JsonParser parser key-fn array-coerce-fn]
  (lazy-seq
   (let [elem (parse/parse parser key-fn eof array-coerce-fn)]
     (when-not (identical? elem eof)
       (cons elem (parsed-seq* parser key-fn array-coerce-fn))))))

