allegro / json-avro-converter

JSON to Avro conversion tool designed to make migration to Avro easier.
Other
277 stars 97 forks source link

Converting classes that have avro fields to json #38

Closed gioragutt closed 5 years ago

gioragutt commented 5 years ago

I have a case where I want to parse a normal, non-avro class to json. I'm using jacksons ObjectMapper, which works for most classes, But fails when a class has Avro members.

Does your library help with this?

adamdubiel commented 5 years ago

No, I don't think it does :)

gioragutt commented 5 years ago

Generally speaking, how would you go about implementing something like this?

adamdubiel commented 5 years ago

Frankly I have no idea - depends on what you want to achieve. How does it fail? Maybe you just need a custom serializer for this type?

gioragutt commented 5 years ago

Basically ObjectMapper does it’a work very stupidly-it iterates on all getters.

Soon as it goes to getSchema, it fails on the first getter that throws an exception - in my case, getValueType which throws something like this is not a map exception.

I’m going to POC creating a derived ObjectMapper which will specially handle Avro values. If this works, let there be a github repo :) if not, we’re gonna change the type to fully avro and save ourselves the time.

adamdubiel commented 5 years ago

AFAIR you can specify which fields to ignore even without using things like custom serializers. However it is just a suggestion since I don't know your exact need. Let me close this issue here :)