Is there an out of the box (de)serializer for UUID in json4s?

时光毁灭记忆、已成空白 提交于 2019-12-30 08:15:08

问题


I'm having a problem very similar to what's described here: Combining type and field serializers

case class(id: Option[UUID], otherValue:String, … )

The answer to the related question would allow me to write my own format, but I'm curious if there is already a format for UUID hiding somewhere in json4s. I'd guessed that the right import would solve this issue for UUID, and I was a bit surprised not to find anything.

Did I miss it, or is it not there yet?


回答1:


Since my pull request was merged, there is JavaTypesSerializers.

Usage:

implicit lazy val formats = Serialization.formats(NoTypeHints) ++ 
                            org.json4s.ext.JavaTypesSerializers.all



回答2:


For someone who is looking for a UUID serializer, it has been included in 3.2.11 version of json4s-ext.

Checkout this:

https://stackoverflow.com/a/25511897/1596111



来源:https://stackoverflow.com/questions/23977779/is-there-an-out-of-the-box-deserializer-for-uuid-in-json4s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!