Module avro_json_encoder

Schema is written following parsing canonical form recommendations but keeps all information (attributes are kept even if they are not relevant for parsing).

Authors: Ilya Staheev (ilya.staheev@klarna.com).

Description

Schema is written following parsing canonical form recommendations but keeps all information (attributes are kept even if they are not relevant for parsing).

Data Types

array_type()

array_type() = #avro_array_type{type = avro:type_or_name(), custom = [avro:custom_prop()]}

avro_type()

avro_type() = primitive_type() | array_type() | enum_type() | fixed_type() | map_type() | record_type() | union_type()

avro_value()

avro_value() = avro:canonicalized_value() | #avro_value{type = avro:type_or_name(), data = avro:avro_value()} | [#avro_value{type = avro:type_or_name(), data = avro:avro_value()}] | [{avro:name(), #avro_value{type = avro:type_or_name(), data = avro:avro_value()}}] | avro_map:data() | {json, binary()} | {binary, binary()}

enum_type()

enum_type() = #avro_enum_type{name = avro:name(), namespace = avro:namespace(), aliases = [avro:name()], doc = avro:typedoc(), symbols = [avro:enum_symbol()], fullname = avro:fullname(), custom = [avro:custom_prop()]}

fixed_type()

fixed_type() = #avro_fixed_type{name = avro:name(), namespace = avro:namespace(), aliases = [avro:name()], size = pos_integer(), fullname = avro:fullname(), custom = [avro:custom_prop()]}

map_type()

map_type() = #avro_map_type{type = avro:type_or_name(), custom = [avro:custom_prop()]}

name_raw()

name_raw() = atom() | string() | binary()

primitive_type()

primitive_type() = #avro_primitive_type{name = avro:name(), custom = [avro:custom_prop()]}

record_type()

record_type() = #avro_record_type{name = avro:name(), namespace = avro:namespace(), doc = avro:typedoc(), aliases = [avro:name()], fields = [avro:record_field()], fullname = avro:fullname(), custom = [avro:custom_prop()]}

type_or_name()

type_or_name() = avro_type() | name_raw()

union_type()

union_type() = #avro_union_type{id2type = avro_union:id2type(), name2id = avro_union:name2id()}

Function Index

encode/3Encode unwrapped (raw) values directly without (possibilly recursive) type info wrapped with values.
encode_schema/1Encode avro schema in JSON format with default options.
encode_schema/2Encode avro schema in JSON format.
encode_type/1Encode avro schema in JSON format.
encode_value/1Encode avro value in JSON format.

Function Details

encode/3

encode(Sc::avro:schema_all(), TypeOrName::type_or_name(), Value::avro:in()) -> iodata()

Encode unwrapped (raw) values directly without (possibilly recursive) type info wrapped with values. i.e. data can be recursive, but recursive types are resolved by schema lookup

encode_schema/1

encode_schema(Type::avro_type()) -> iodata()

Encode avro schema in JSON format with default options.

encode_schema/2

encode_schema(Type0::avro_type(), Opt::avro:schema_opts()) -> iodata()

Encode avro schema in JSON format. Encode parsing canonical form format if canon option is enabled

encode_type/1

encode_type(Type::avro_type()) -> iodata()

Encode avro schema in JSON format.

encode_value/1

encode_value(Value::avro_value()) -> iodata()

Encode avro value in JSON format.


Generated by EDoc