This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-30
Channels
- # adventofcode (22)
- # announcements (7)
- # beginners (32)
- # calva (56)
- # cider (96)
- # cljdoc (7)
- # cljs-dev (50)
- # clojure (173)
- # clojure-austin (8)
- # clojure-brasil (7)
- # clojure-europe (10)
- # clojure-greece (2)
- # clojure-italy (10)
- # clojure-nl (9)
- # clojure-spec (18)
- # clojure-uk (143)
- # clojurebridge (3)
- # clojurescript (9)
- # cursive (14)
- # data-science (1)
- # datascript (4)
- # datomic (9)
- # docker (7)
- # emacs (2)
- # figwheel-main (4)
- # fulcro (18)
- # garden (1)
- # graphql (13)
- # hyperfiddle (4)
- # juxt (2)
- # off-topic (43)
- # pathom (1)
- # pedestal (17)
- # portkey (163)
- # re-frame (4)
- # reitit (7)
- # rum (4)
- # shadow-cljs (139)
- # spacemacs (5)
- # sql (14)
- # unrepl (2)
@kanwei here's a guide: https://cljdoc.org/d/metosin/muuntaja/0.6.1/doc/configuration#setting-transit-writers-and-readers
for Java8 dates, I think they could be supported oob, as Jsonista does it for JSON and Java8 is required anyway, wrote: https://github.com/metosin/muuntaja/issues/92
@ikitommi thanks, I actually dug into the transit-clj implementation and it basically wraps around transit-java, which seems to hardcode a lot of mappings. Since transit is supposed to be extendable, should we be doing something like this? https://blog.klipse.tech/clojure/2016/09/22/transit-clojure-2.html
@kanwei exactly. The example was kinda bad, as the readers
& writers
were not explained. But those are the maps from the tutorial.
something like (joda example):
(ns metosin.transit.dates
"Transit readers and writers for JodaTime and goog.date.
Supports two types:
- DateTime (org.joda.time.DateTime, goog.date.UtcDateTime)
- LocalDate (org.joda.time.LocalDate, goog.date.Date)
Represents DateTimes in RFC 3339 format: yyyy-mm-ddTHH:MM:SS.sssZ.
RFC 3339 format is an specific profile of ISO 8601 DateTime format.
Some consideration has been made to provide performant read
implemenation for ClojureScript."
(:require [cognitect.transit :as transit]
[metosin.dates :as d]))
(def writers
{#?(:clj org.joda.time.DateTime, :cljs goog.date.UtcDateTime)
(transit/write-handler (constantly "DateTime") d/to-string)
#?(:clj org.joda.time.LocalDate, :cljs goog.date.Date)
(transit/write-handler (constantly "Date") d/to-string)})
(def readers
; 1 argument arity version must be explicitly used for clojurescript
{"DateTime" (transit/read-handler #(d/date-time %))
"Date" (transit/read-handler #(d/date %))})