avsc-json-sample
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

avsc json sample

This lib allows you to generate sample json documents from an Apache Avro schema.

To use it you have to wrap your schema in an avsc schema and call the function avscJsonSample() from this library

Sample usage

Install avsc and avsc-json-sample libs

npm i avsc avsc-json-sample

Then use it in your code

const avro = require("avsc");
const { avscJsonSample } = require("avsc-json-sample");

const avscType = avro.Type.forSchema({
  type: "record",
  fields: [
    { name: "kind", type: { type: "enum", symbols: ["CAT", "DOG"] } },
    { name: "name", type: "string" },
    { name: "age", type: "int" },
  ],
});

const jsonSample = avscJsonSample(avscType);
console.log(jsonSample); // { kind: 'CAT', name: 'string', age: 0 }

Have fun 🤩

Useful links

Package Sidebar

Install

npm i avsc-json-sample

Weekly Downloads

61

Version

1.0.1

License

ISC

Unpacked Size

8.35 kB

Total Files

8

Last publish

Collaborators

  • delphinaubin