Combining type and field serializers

前端 未结 2 1021
刺人心
刺人心 2021-01-04 08:06

Let\'s assume I have a case class with the following setup:

case class Place(id:java.util.UUID, name:String)

I can write a (working!) seria

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 08:36

    There is now a UUID serializer provided in the extras package of json4s. It will most likely be available in version 3.2.11 (which has not been released as of this writing).

    You'll be able to do something like this:

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

    This was taken from the tests for this feature's PR.

提交回复
热议问题