 (ns assert-json.core
-  (:use [cheshire.core :as json :only [parse-string]]
+  (:use [cheshire.core :as cheshire :only [parse-string]]
         [assert-json.exceptions :only [property-not-found
                                        wrong-property-type
                                        wrong-property-value]]))

          (not= value m-val) (throw (wrong-property-value property m-val value))
          :default true)))

(defmacro assert-json 
  "Assert JSON properties (and corresponding values) in a convenient form.
  
  Example:

     (map (fn [c#] (assert-property m# (first c#) (second c#))) 
          (partition 2 (vector ~@body)))))

(defn assert-json
  "Assert JSON properties on a `json-string`, setting expectations via an `expected` map. 
  
  Properties are asserted for presence, and their values for type and equality."
  [json-string expected]
  (let [json (parse-string json-string)]
    (map #(assert-property json (first %) (second %)) 
         expected)))


