Code Monkey home page Code Monkey logo

Comments (9)

cescoffier avatar cescoffier commented on June 18, 2024

Looking into it.

from vertx-config.

cescoffier avatar cescoffier commented on June 18, 2024

@ufoscout I've tried to reproduce it in Java and in Kotlin but failed. Can you provide a reproducer?

from vertx-config.

ufoscout avatar ufoscout commented on June 18, 2024

@cescoffier
After some investigations, I found that the issue happens only when the default Json.mapper is set to the Jackson mapper for Kotlin. E.g., this causes the bug:

       Json.mapper = com.fasterxml.jackson.module.kotlin.jacksonObjectMapper()
       Json.prettyMapper = com.fasterxml.jackson.module.kotlin.jacksonObjectMapper()

At this point I am not sure what/where is the issue since the mapper works fine everywhere else.

from vertx-config.

vietj avatar vietj commented on June 18, 2024

@ufoscout would you mind try this on your mappers:

    // custom types
    module.addSerializer(JsonObject.class, new JsonObjectSerializer());
    module.addSerializer(JsonArray.class, new JsonArraySerializer());
    // he have 2 extensions: RFC-7493
    module.addSerializer(Instant.class, new InstantSerializer());
    module.addSerializer(byte[].class, new ByteArraySerializer());

and see if that fixes the problem ?

from vertx-config.

ufoscout avatar ufoscout commented on June 18, 2024

@vietj
Yes, indeed adding those serializers fixes the issue. However, they are declared as private into the Json class, so there is no way to reuse them.
Nevertheless, I found a better solution. In fact, instead of overriding the Json mappers, I can extend them by adding the KotlinModule:

        Json.mapper.registerModule(KotlinModule())
        Json.prettyMapper.registerModule(KotlinModule())

This is more maintainable and works as expected.
Probably this should be reported somewhere in the kotlin support documentation.

from vertx-config.

vietj avatar vietj commented on June 18, 2024

@ufoscout thanks for reporting, I think actually we will add documentation in vertx-core as this is a not only kotlin issue.

from vertx-config.

ufoscout avatar ufoscout commented on June 18, 2024

@vietj
Why do you have a custom serializer for the Instant class? Shouldn't you instead register the JavaTimeModule provided by Jackson?

from vertx-config.

vietj avatar vietj commented on June 18, 2024

@ufoscout I think @pmlopes can elaborate on it

from vertx-config.

cescoffier avatar cescoffier commented on June 18, 2024

Closing this issue, not related to vert.x config.

from vertx-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.