Class CompositeJsonToAvroReader

java.lang.Object
tech.allegro.schema.json2avro.converter.CompositeJsonToAvroReader
All Implemented Interfaces:
JsonToAvroReader

public class CompositeJsonToAvroReader extends Object implements JsonToAvroReader
  • Constructor Details

    • CompositeJsonToAvroReader

      public CompositeJsonToAvroReader()
    • CompositeJsonToAvroReader

      public CompositeJsonToAvroReader(List<AvroTypeConverter> additionalConverters)
      this constructor allows you to specify custom converters. It can be used to convert custom java types, or avro schema with logical type.
      Parameters:
      additionalConverters - additional converters that implement AvroTypeConverter. These converters will override default converters.
    • CompositeJsonToAvroReader

      public CompositeJsonToAvroReader(AvroTypeConverter... additionalConverters)
      this constructor allows you to specify custom converters. It can be used to convert custom java types, or avro schema with logical type.
      Parameters:
      additionalConverters - additional converters that implement AvroTypeConverter. These converters will override default converters.
    • CompositeJsonToAvroReader

      public CompositeJsonToAvroReader(List<AvroTypeConverter> additionalConverters, UnknownFieldListener unknownFieldListener)
      this constructor allows you to specify custom converters. It can be used to convert custom java types, or avro schema with logical type.
      Parameters:
      additionalConverters - additional converters that implement AvroTypeConverter. These converters will override default converters.
      unknownFieldListener - the listener to customize unknown field error management
  • Method Details

    • createMainConverter

      protected AvroTypeConverter createMainConverter(UnknownFieldListener unknownFieldListener)
    • read

      public org.apache.avro.generic.GenericData.Record read(Map<String,Object> json, org.apache.avro.Schema schema)
      Description copied from interface: JsonToAvroReader
      convert a Map to a generic record
      Specified by:
      read in interface JsonToAvroReader
      Parameters:
      json - the json to convert
      schema - the avro schema to use
      Returns:
      the converted Record
    • read

      public Object read(org.apache.avro.Schema.Field field, org.apache.avro.Schema schema, Object jsonValue, Deque<String> path, boolean silently)
      Description copied from interface: JsonToAvroReader
      allow to convert a json field to type corresponding avro type
      Specified by:
      read in interface JsonToAvroReader
      Parameters:
      field - the avro field to create
      schema - the schema associated to the field
      jsonValue - the json jsonValue of the field
      path - the path of the field on the json
      silently - should be false to throw an error in case of incompatible java type for the avro type
      Returns:
      the converted jsonValue