Closed lizas2110 closed 4 years ago
Hi!
Since avsc
is a peer dependency you'll have that installed already and you can do that (code mostly copied from the README from there):
const avro = require('avsc');
const type = avro.Type.forSchema({
type: 'record',
fields: [
{name: 'kind', type: {type: 'enum', symbols: ['CAT', 'DOG']}},
{name: 'name', type: 'string'}
]
});
const val = type.fromBuffer(buf);
If your message contains the ID in the buffer you need to cut out the first 5 bytes (1 magic byte + 4 id bytes), you can read about that here
Let me know if you need any help!
Hey, when using decode/decodeMessage function, is it possible to pass a schema and decode the message by the given schema and not only by the schema witch attached to the message?