Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

avroize-es6

avroize31MIT0.1.4

avroize-es6

readme

avroize-es6

Build Status Coverage Status npm version

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}