Announcement Announcement Module
Collapse
No announcement yet.
Using generics with json-to-object-transformer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using generics with json-to-object-transformer

    We are using a generic payload in our custom Message.
    Is there any way of specifying a generic type with the json-to-object-transformer?

    If not, then the next best solution I can see is to have a custom object-mapper.
    Is this correct?

    Many thanks

  • #2
    No, currently the standard j-t-o-t only uses the version of ObjectMapprt.readValue() that takes a class.

    For generics, you have to use the method that takes a JavaType (which has been apropriately constructed for the required generic type.

    I suggest you use a simple <transformer/> with a reference to a custom object that performs the transformation using this advanced configuration on the ObjectMapper.

    If you come up with something that you think would have wide appeal, consider contributing it back to the community - https://github.com/SpringSource/spri...ONTRIBUTING.md

    Comment

    Working...
    X