'how to convert flatbuffer .fbs file to .bin file
i am learning flatbuffers in java
I want to create a .bin file from .fbs file and I don't have .json file already how do i create a json file so that I can create a bin file?
as they already had mosterdata.json file in thier sample code but what if we don't have the JSON file? and we just had the .fbs file and it's generated java code only?
as mentioned here how will i get the data file ?
Solution 1:[1]
There are two ways to make your .bin file.
Use JSON to specify the contents.
flatc -b <your_schema.fbs> <your_data.json>Where
-bmeans generate a binary file.To make
your_data.jsonyou'll have to make it yourself, usingyour_schema.fbsto guide you on how to specify the json fields. I would check out how themonsterdata_test.jsonis specified by its corresponding schemamonster_test.fbs
Use
flatcto output the Java code gen, and then programmatically generate the.binusing the generated code.flatc --java <your_schema.fbs>This way is a lot more involved, since you have to make a program that uses the generated code and output the binary yourself. Check out the tutorial (switch to the java language) for example usage.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Moop |
