confluentinc / schema-registry

Confluent Schema Registry for Kafka
https://docs.confluent.io/current/schema-registry/docs/index.html
Other
2.21k stars 1.11k forks source link

Unable to omit null fields in avro JSON serialization if default value is also null #3159

Open harshaspace opened 3 months ago

harshaspace commented 3 months ago

Hello,

Can we have an option to omit null fields from the JSON provided that the default value is also null ? It helps to reduce the size of the JSON file and also consumer side will not affect with this kind of behaviour.

For instance, JSON serializers like Jackson, gson already have a similar feature to ignore null fields. (@JsonInclude(Include.NON_NULL))

Thanks!

harshaspace commented 3 months ago

I found similar feature ticket in apache avro project, not sure how does it apply to confluent: https://issues.apache.org/jira/browse/AVRO-1582

rayokota commented 3 months ago

You can annotate your POJO with @JsonInclude(Include.NON_NULL)

harshaspace commented 2 months ago

@rayokota This didn't help as it uses avro serialization. These are I think Jackson annotations