Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JacksonJson cannot be used with akka serialization as a jackson module #770

Open
jona7o opened this issue Jun 20, 2022 · 0 comments
Open

Comments

@jona7o
Copy link

jona7o commented Jun 20, 2022

Hi,

i would be great if you could add another class without class parameters to
https://github.com/playframework/play-json/blob/main/play-json/jvm/src/main/scala/play/api/libs/json/jackson/JacksonJson.scala

Something like:

class JacksonJsonModule() extends SimpleModule("JacksonJsonModule", Version.unknownVersion()) {
  val parserSettings = JsonParserSettings()
  override def setupModule(context: SetupContext): Unit = {
    context.addDeserializers(new PlayDeserializers(parserSettings))
    context.addSerializers(new PlaySerializers(parserSettings))
  }
}

Why i think it is useful? Because i want to register the JacksonJson in the akka config, and akka can just create an instance of the class if it has no parameters.

akka.serialization.jackson {
    jackson-modules += "[..].JacksonJsonModule" # <--- Right now this is not possible
}

It is useful if you use JsValue in a case class which gets serialized by akka. When it comes to deserialization you now enter in an

InvalidDefinitionException: Cannot construct instance of ... (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

Perhaps you have another solution, but my current solution was to fork the file and add a class like mentioned for my purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant