You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/09/30 14:01:35 UTC

[GitHub] [pulsar] tomas-c commented on issue #6528: JSONSchema Deserializer does not work with kotlin data classes

tomas-c commented on issue #6528:
URL: https://github.com/apache/pulsar/issues/6528#issuecomment-701410483


   Since #6905 has been merged, it's now possible to create a schema that uses a custom ObjectMapper like so:
   
   ```
   val objectMapper= ObjectMapper()
   objectMapper.registerModule(KotlinModule())
   objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
   objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
   
   val schemDefinition = SchemaDefinition.builder<YourClass>()
               .withPojo(YourClass::class.java)
               .withSchemaReader(JacksonJsonReader(objectMapper, YourClass::class.java))
               .withSchemaWriter(JacksonJsonWriter(objectMapper))
               .build()
   ```
   
   Note that this only works with the unshaded version of the library (use org.apache.pulsar:pulsar-client-original instead of org.apache.pulsar:pulsar-client)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org