FlatBuffer 使用

参考资料:
国外最早教FlatBuffer使用的家伙。
https://medium.freecodecamp.com/why-consider-flatbuffer-over-json-2e4aa8d4ed07#.g0li3oki8

Windows 7 64位 cmake 安装
https://cmake.org/download/

FlatBuffer 源码
https://github.com/google/flatbuffers

步骤:
1 下载源代码
2 编译出flatc ,执行文件。用于翻译你的描述文件。
3 编写对应描述文件,翻译成对应语言的类。把对应的类, 放到你的工程中。

英文步骤:
How to start with flatBuffer

Run the command on the basis of your platform

  • $ cmake -G “Unix Makefiles”
  • $ cmake -G “Visual Studio 10”
  • $ cmake -G “Xcode”

now build for your platform as usual. This should result in a flatc executable
Now create your schema file with extension .fbs. Guide to write a schema can be found here.And also have your sample json file.

  • $ ./flatc -j -b schema.fbs sample.json

This will create few java file and one bin file. Java files are like model(POJO for flatBuffer) of your json.Place the java files in your application package and bin file in raw folder(bin file is only for testing as it is converted to byte that is to be passed to flatbuffer for testing).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值