Re: Extending clojure.contrib.json.write/print-json

2009-05-14 Thread Josip Gracin

On Thu, May 14, 2009 at 1:57 AM, Stuart Sierra
 wrote:
> The latest version of c.c.json dispatches on the "type" function,
> which in turn uses "class."  It should be pretty easily extendible.

Thanks!

-- 
mr.sc. Josip Gracin, dipl.ing.
direktor razvoja
Inge-mark d.o.o., Zavrtnica 17, Zagreb
tel: +38516658139, +385919009420

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Extending clojure.contrib.json.write/print-json

2009-05-13 Thread Stuart Sierra

Hi Josip,
The latest version of c.c.json dispatches on the "type" function,
which in turn uses "class."  It should be pretty easily extendible.
-Stuart Sierra

On May 12, 9:26 am, Josip Gracin  wrote:
> Hi!
>
> I'm querying a DB and getting java.sql.Timestamp in results, among
> other things.  When I use print-json on this, timestamps are
> serialized as #.
>
> Stuart, any chance you could make the dispatch function for
> clojure.contrib.json.write/print-json more open for extensions?
> Unless I'm missing something, changing ":else :default" to ":else
> (class x)" in the print-json dispatch fn definition would enable
> adding serialization for custom objects.
>
> (defmulti
>   print-json (fn [x]
>                (cond (nil? x) nil
>                      (map? x) :object
>                      (coll? x) :array
>                      (keyword? x) :keyword
>                      :else :default)))
>
> --
> mr.sc. Josip Gracin, dipl.ing.
> direktor razvoja
> Inge-mark d.o.o., Zavrtnica 17, Zagreb
> tel: +38516658139, +385919009420
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Extending clojure.contrib.json.write/print-json

2009-05-13 Thread Tom Faulhaber

Josip,

You might want to look at Dan Larkin's clojure-json library at
http://github.com/danlarkin/clojure-json which supports extensions via
dispatch as you suggest.

Tom

On May 12, 6:26 am, Josip Gracin  wrote:
> Hi!
>
> I'm querying a DB and getting java.sql.Timestamp in results, among
> other things.  When I use print-json on this, timestamps are
> serialized as #.
>
> Stuart, any chance you could make the dispatch function for
> clojure.contrib.json.write/print-json more open for extensions?
> Unless I'm missing something, changing ":else :default" to ":else
> (class x)" in the print-json dispatch fn definition would enable
> adding serialization for custom objects.
>
> (defmulti
>   print-json (fn [x]
>                (cond (nil? x) nil
>                      (map? x) :object
>                      (coll? x) :array
>                      (keyword? x) :keyword
>                      :else :default)))
>
> --
> mr.sc. Josip Gracin, dipl.ing.
> direktor razvoja
> Inge-mark d.o.o., Zavrtnica 17, Zagreb
> tel: +38516658139, +385919009420
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Extending clojure.contrib.json.write/print-json

2009-05-12 Thread Josip Gracin

Hi!

I'm querying a DB and getting java.sql.Timestamp in results, among
other things.  When I use print-json on this, timestamps are
serialized as #.

Stuart, any chance you could make the dispatch function for
clojure.contrib.json.write/print-json more open for extensions?
Unless I'm missing something, changing ":else :default" to ":else
(class x)" in the print-json dispatch fn definition would enable
adding serialization for custom objects.

(defmulti
  print-json (fn [x]
   (cond (nil? x) nil
 (map? x) :object
 (coll? x) :array
 (keyword? x) :keyword
 :else :default)))



-- 
mr.sc. Josip Gracin, dipl.ing.
direktor razvoja
Inge-mark d.o.o., Zavrtnica 17, Zagreb
tel: +38516658139, +385919009420

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---