jodatime - scala json4s, can't convert LocalDate -


i'm having issue org.json4s (scala), joda.time.localdate , org.json4s.ext.jodatimeserializers. given jodatimeserializers.all has localdate conversion in it, hoping following, exception shown after

scala> import org.json4s.jstring import org.json4s.jstring  scala> import org.joda.time.localdate import org.joda.time.localdate  scala> import org.json4s.ext.jodatimeserializers import org.json4s.ext.jodatimeserializers  scala> import org.json4s._ import org.json4s._  scala> implicit val formats: formats = defaultformats ++ jodatimeserializers.all formats: org.json4s.formats = org.json4s.formats$$anon$3@693d3d7f  scala> val jdate = jstring("2016-01-26") jdate: org.json4s.jsonast.jstring = jstring(2016-01-26)  scala> jdate.extract[localdate] org.json4s.package$mappingexception: can't convert jstring(2016-01-26) class org.joda.time.localdate 

other other hand, works (not surprisingly)

scala> val jodadate = localdate.parse(jdate.values) 

i've tried create custom serializer, never gets called b/c falls jodaserializer realm seems. have created custom deserializer work java.time.localdate (int , bytes strings), java.time.localdate messes other code different question...this 1 is: i'm looking clues jodatimeserializers.all can not parse jstring(2016-01-26), or date string.

the top of exception is: org.json4s.package$mappingexception:

can't convert jstring(2016-01-01) class org.joda.time.localdate (jodatimeserializers.scala:126) 

edit still biting me, dug bit further , reproducible following.

import org.joda.time.localdate import org.json4s.ext.jodatimeserializers import org.json4s._ implicit val formats: formats = defaultformats ++ jodatimeserializers.all import org.joda.time.localdate case class mydate(mydate: localdate) val stringydate = """ {   "mydate" : "2016-01-01" } """ import org.json4s.jackson.jsonmethods.parse parse(stringydate).extract[mydate]  org.json4s.package$mappingexception: no usable value mydate can't convert jstring(2016-01-01) class org.joda.time.localdate 

this seems happen b/c on line 125 of jodatimeserializers.scala, not jobject, jstring, falls value case on line 126, throws error.

adding here in case bites else , assistance fixing it...but i'm late. have moved code locally come fix tomorrow.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -