//using Node.js
//npm install avsc
class Size {
constructor(width, height) {
this.width = width;
this.height = height;
}
}
class Rect {
constructor(size) {
this.size = size;
}
}
let rect = new Rect(new Size(5, 10));
//Encoding Binary Data
const avsc = require('avsc');
const type = avsc.Type.forValue(rect);
const data_b = type.toBuffer(rect);
//Decoding Binary Data
const rect2 = type.fromBuffer(data_b);
//Recordnbsp;{ size: Recordnbsp;{ width: 5, height: 10 } }
console.log("rect2 is", rect2);