Class CompositeJsonToAvroReader
java.lang.Object
tech.allegro.schema.json2avro.converter.CompositeJsonToAvroReader
- All Implemented Interfaces:
JsonToAvroReader
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeJsonToAvroReader(List<AvroTypeConverter> additionalConverters) this constructor allows you to specify custom converters.CompositeJsonToAvroReader(List<AvroTypeConverter> additionalConverters, UnknownFieldListener unknownFieldListener) this constructor allows you to specify custom converters.CompositeJsonToAvroReader(AvroTypeConverter... additionalConverters) this constructor allows you to specify custom converters. -
Method Summary
Modifier and TypeMethodDescriptionprotected AvroTypeConvertercreateMainConverter(UnknownFieldListener unknownFieldListener) org.apache.avro.generic.GenericData.Recordconvert a Map to a generic recordread(org.apache.avro.Schema.Field field, org.apache.avro.Schema schema, Object jsonValue, Deque<String> path, boolean silently) allow to convert a json field to type corresponding avro type
-
Constructor Details
-
CompositeJsonToAvroReader
public CompositeJsonToAvroReader() -
CompositeJsonToAvroReader
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 implementAvroTypeConverter. These converters will override default converters.
-
CompositeJsonToAvroReader
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 implementAvroTypeConverter. 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 implementAvroTypeConverter. These converters will override default converters.unknownFieldListener- the listener to customize unknown field error management
-
-
Method Details
-
createMainConverter
-
read
public org.apache.avro.generic.GenericData.Record read(Map<String, Object> json, org.apache.avro.Schema schema) Description copied from interface:JsonToAvroReaderconvert a Map to a generic record- Specified by:
readin interfaceJsonToAvroReader- Parameters:
json- the json to convertschema- 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:JsonToAvroReaderallow to convert a json field to type corresponding avro type- Specified by:
readin interfaceJsonToAvroReader- Parameters:
field- the avro field to createschema- the schema associated to the fieldjsonValue- the json jsonValue of the fieldpath- the path of the field on the jsonsilently- should be false to throw an error in case of incompatible java type for the avro type- Returns:
- the converted jsonValue
-