On Fri, Oct 25, 2019 at 8:33 PM Amit Singh <[email protected]> wrote: > > Correct me if I am wrong, but the approach you described works well when I > want to serialize the POJO into JSON (by using a custom serializer and > overriding serialize method). However, what I actually want to achieve is > change how POJO is used to obtain the AVRO schema from the POJO. I want to > generate an AVRO schema that is able to parse Mongo generated JSON. Now as I > said, Mongo stores ObjectId as : > 'id' : { > 'oid' : '24-character-hex-string'; > } > So, is there any way to override some methods and get that? It's something > similar to the JSON serialization you said about, but for AVRO schema > generation.
Yes, schema generation (used for JSON Schema as well as Avro schema) relies in `JsonSerializer` that type uses, in particular method "acceptJsonFormatVisitor()". You would need to register a custom serializer for `ObjectId`. You can have a look at how existing standard serializers implement this method -- it's not a very interface but it's the way to do it. Hope this helps, -+ Tatu +- -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CAL4a10h%2B2nnZqGOJSTw4bvg%3Dvorc_vGU-Cu6jJ27WfW45Jmoig%40mail.gmail.com.
