I have my own custom DateTime class for which I wrote the following custom writer and reader:
val dtWriter = Writer[DateTime]{
case t => Js.Str(format(t))
}
val dtReader = Reader[DateTime]{
case Js.Str(time) =>
try {
parse(time)
}
catch {
case _: Exception =>
SDateTime(0)
}
}
However, I tried to upgrade my package version from 0.4.4 to 0.7.1 and this code no longer compiles giving me the following errors:
Error:(7, 8) object Js is not a member of package upickle
import upickle.Js
Error:(112, 23) object Writer does not take type parameters.
val dtWriter = Writer[DateTime]{
How should this be rewritten in the latest version of upickle?
Based just on reading http://www.lihaoyi.com/upickle/#CustomPicklers:
val dtRW = readwriter[String].bimap[DateTime](
t => format(t), // also `format _` or just `format` should work
time =>
try {
parse(time)
}
catch {
case _: Exception =>
SDateTime(0)
}
)