Comments (3)
Thanks for reporting this issue!
Serializing and deserializing scala enums is not trivial to implement, here you can find some details: https://github.com/FasterXML/jackson-module-scala/wiki/Enumerations
As a temporary workaround I would suggest you using:
- Java enums (in a mixed Scala/java project), or
- implementing the enum as sealed case objects and registering a custom serializer and deserializer for it
from java-velocypack-module-scala.
Alternatively, you can use jackson-dataformat-velocypack in combination with jackson-module-scala. It (partially) supports scala enumeration mapping, as documented here: https://github.com/FasterXML/jackson-module-scala/wiki/Enumerations
Eg. something like this:
import com.arangodb.jackson.dataformat.velocypack.VPackMapper
import com.fasterxml.jackson.core.`type`.TypeReference
import com.fasterxml.jackson.module.scala.{DefaultScalaModule, JsonScalaEnumeration}
object Weekday extends Enumeration {
type Weekday = Value
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
}
class WeekdayType extends TypeReference[Weekday.type]
case class WeekdayHolder(@JsonScalaEnumeration(classOf[WeekdayType]) weekday: Weekday.Weekday)
object HelloWorld {
def main(args: Array[String]): Unit = {
val obj = WeekdayHolder(Weekday.Fri)
val mapper = new VPackMapper().registerModule(DefaultScalaModule)
val bytes = mapper.writeValueAsBytes(obj)
val decodedBytes: WeekdayHolder = mapper.readValue(bytes, classOf[WeekdayHolder])
assert(decodedBytes.weekday == Weekday.Fri)
}
}
from java-velocypack-module-scala.
thanks, will take look.
from java-velocypack-module-scala.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-velocypack-module-scala.