FasterXML / jackson-module-scala

Add-on module for Jackson (https://github.com/FasterXML/jackson) to support Scala-specific datatypes
Apache License 2.0
501 stars 141 forks source link

JsonScalaEnumeration with collection Seq/Set #582

Closed randers-bit closed 2 years ago

randers-bit commented 2 years ago

Hello i read FAQ and i know that when serializing Enumerations @JsonScalaEnumeration annotations should be used like described.

But what to do when enumeration is in collecion like Set/Seq?

I asked on stack overflow in context of swagger - Stack Overflow question but now i encountered old version of enumeration serialization in akka persistence and im concerned how to resolve this.

I it seems like missing documentation or functionality for this.

pjfanning commented 2 years ago

This project is unaffiliated with swagger-akka-http - closing - I will open an issue over there

pjfanning commented 2 years ago

https://github.com/swagger-akka-http/swagger-scala-module/issues/154

pjfanning commented 2 years ago

PS that JsonScalaEnumeration only works with enum instances directly, not if they are wrapped by collections.

randers-bit commented 2 years ago

I found that myself about JsonScalaEnumeration, like i wrote in stack overflow. In swagger i found answer acceptable for generating proper swagger file but now im concerned about journal in akka persistence.

I found that in journal enums in array are generated like in wiki for deprecated version {"weekday":{"enumClass":"Weekday","value":"Fri"}} but i didn't saw any deprecation warnings in logs or anything, and it seems to work properly.

It is safe to assume that this format will work and just leave it or i should be worried about it in future/now?

pjfanning commented 2 years ago

I don't know anything about akka persistence. I never ever use Scala 2 enumerations. They are not deprecated but there are better alternatives - Enumeratum for Scala 2 and the new Scala 3 enums if you want to use Scala 3.

There are some tests relating to Scala 2 enumerations that don't work in Scala 3 - eg https://github.com/FasterXML/jackson-module-scala/issues/535

randers-bit commented 2 years ago

Thank you for your answers @pjfanning :)