A binary serialize framework
npm install xcore-xdata
npm install xcore-xdata
`2. import
`
import {XData,XDataWriter,XDataParser} from 'xcore-xdata'`
3. Serialize to byte array:
1 visit https://xcore.top to design a model .for example An UserModel(username,password).
2 download the source code and put in your source dir. you will get the source file UserModelWrapper.js
`
let user = new UserWrapper();
user.name = "Jim Green"
user.password = "111111"
let writer = new XDataWriter();
let bytes = writer.write(user);
`bytes is an arraybuffer, you can send it to anywhere you like.
4. Deserialize
serialize the bytes (you can get from a XData stream) back to userwraper model:
`
let parser = new XDataParser();
let xdata = parser.parse(bytes);
let user = new UserWrapper(xdata);
console.log(user.name) // will print Jim Green
console.log(user.password) // will print 111111`` |order|datatype | single |List | Set | StringMap|IntMap | LongMap | FloatMap |DoubleMap |
|-----|-----|---------| ---------|--------|----------|-------|---------|----------|----------|
|1|int8|number|List\
|2|int16|number|List\
|3|int32|number|List\
|4|int64|number|List\
|5|float32|number|List\
|6|float64|number|List\
|7|boolean|boolean|List\
|8|String|String|List\
|9|Date|Date|List\
|10|ArrayBuffer|ArrayBuffer|List\
|11|XData|XData|List\