cognitect / transit-cljs

Transit for ClojureScript
http://transit-format.org
Apache License 2.0
323 stars 20 forks source link

Add documentation to point out that UUID is a cct type, not a cc type #18

Closed danielcompton closed 2 years ago

danielcompton commented 8 years ago

In the past people have been confused using UUID's in Transit. Transit-cljs uses a custom cct UUID type, not a native CLJS UUID. It would be good to explicitly point this out in the documentation and show how people can override this behaviour if they want to get CLJS UUID's.

This could be something like:

Transit-cljs returns custom com.cognitect.transit types by default for some values, including UUID's. To override this and return native ClojureScript UUID's, add a custom read handler for u. This will override the default read handler.

(t/reader :json {:handlers {"u" cljs.core/uuid} })

Relates to #11

darkleaf commented 7 years ago

Another problem and fix. com.cognitect.transit.types/UUID are equivalent of UUID. But cljs.core/uuid? not work with com.cognitect.transit.types/UUID.

Fix:

(ns some.namespace
  (:require [com.cognitect.transit.types :as ty]))

(extend-type ty/UUID
  IUUID)
swannodette commented 2 years ago

Fixed in master.