avroize-es6
Transform your data into valid Avro JSON for any given Avro schema.
Support for MVP release:
- Primitive types: Boolean, Double, Float, Integer, Long, String
- Complex types: Arrays, Records, Unions (null only)
- JSON Avroizer
Getting Started
Install Avroize using npm
:
npm install --save avroize-es6
Avroize JSON data:
import {getJSONAvroizer} from 'avroize-es6'
const avroSchema = {
"name": "example",
"namespace": "avro.test",
"type": "record",
"fields":[{
"default": "",
"name": "field1",
"type": "string"
},{
"default": null,
"name": "field2",
"type": ["null", "string"]
}]
};
const avroizer = getJSONAvroizer(avroSchema);
const result = avroizer.avroize({"field1":"test"});
console.log(result); // {"field1": "test", "field2": null}