The Avro 1.8.2, released on May 15, already contains the JS version of the code.
Tsinghua University Mirror Address:
https://mirrors.tuna.tsinghua.edu.cn/apache/avro/avro-1.8.2/js/
According to README.MD, run a simple example.
Specific steps:
1. Unzip the downloaded compressed package
2. Under the package directory, create a simple file index.js with the following content:
var Avro = require ("./lib/index");
var type = Avro.parse ({
Name: ' Pet ',
Type: ' Record ',
Fields: [
{name: ' Kind ', type: {name: ' Kind ', type: ' enum ', symbols: [' CAT ', ' DOG '}},
{name: ' name ', type: ' String '}
]
});
var pet = {kind: ' CAT ', Name: ' Albert '};
var buf = Type.tobuffer (PET); Serialized object.
var obj = Type.frombuffer (BUF); {kind: ' CAT ', Name: ' Albert '}
Console.log (obj)
Console.log (PET)
Console.log (Obj==pet)
3. Open the command line, switch to the package directory, and execute node index.js
If there is no NODEJS environment, you need to go to Nodejs official website to download the installation, install and run node Index.js may be prompted underscore can not find,
Execute node install underscore at the command line.
Avro 1.8.2 (JS)