avro fields not in schema

node v18.11.0
version: 1.0.0
endpointsharetweet
const avro = require('avsc'); const type = avro.Type.forSchema({ type: 'record', name: 'Pet', fields: [ { name: 'kind', type: {type: 'enum', name: 'PetKind', symbols: ['CAT', 'DOG']} }, {name: 'name', type: 'string'} ] }); const input = {kind: 'CAT', name: 'Albert', extraField: 'nope'}; const buf = type.toBuffer(input); // Encoded buffer. const val = type.fromBuffer(buf); // = {kind: 'CAT', name: 'Albert'} console.log('in', input); console.log('out', val);
Loading…

no comments

    sign in to comment