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

Support for non map based StdSerializer #47

Closed
Cybermaxke opened this issue Feb 1, 2020 · 2 comments
Closed

Support for non map based StdSerializer #47

Cybermaxke opened this issue Feb 1, 2020 · 2 comments
Labels

Comments

@Cybermaxke
Copy link

Given the following custom StdSerializer, it's not possible to serialize my custom object as a String without getting errors. An json object is expected because it needs to be able to convert to a Map. So far it doesn't seem to affect deserialization.

The following example isn't supported: (example error: https://paste.ubuntu.com/p/MhTV9333Qr/)

internal class TextSerializer : StdSerializer<Text>(Text::class.java) {

  override fun serialize(value: Text, gen: JsonGenerator, provider: SerializerProvider) {
    gen.writeString(value.toPlain())
  }
}

This works:

internal class TextSerializer : StdSerializer<Text>(Text::class.java) {

  override fun serialize(value: Text, gen: JsonGenerator, provider: SerializerProvider) {
    gen.writeStartObject()
    gen.writeStringField("text", value.toPlain())
    gen.writeEndObject()
  }
}
@stale
Copy link

stale bot commented May 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot added the stale label May 1, 2020
@uchuhimo uchuhimo added 0.23.0 and removed stale labels Oct 8, 2020
@uchuhimo
Copy link
Owner

@Cybermaxke I have released a new version v0.23.0 that supports non-map based StdSerializer. You can try it now. Any further feedback is welcome.

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

Successfully merging a pull request may close this issue.

2 participants