I have a related question here.
I have a similar use case where the client communicates with the server in JSON. I would like to use FlatBuffers to store the data in binary and deserialize it when I populate the views of my application. How can I leverage both? I'm doing this for a simple android app.
Steps:
1. Define a schema (using the fields of the JSON response). Do I need to have a sample response loaded on disk? Can the fields of the response change? What if new fields get added to the response?
2. Convert to a binary file using flatc.
3. When data comes back from server, I parse the response (in JSON) to model objects.
4. I create the FBB object. Assume that Model is top level class I have deserialized the JSON to.
FlatBufferBuilder fbb = new FlatBufferBuilder(size);
fbb.createString(response);
int model = Model.endModel(fbb);
fbb.finish(repo);
// Persist
byte[] result = fbb.sizedByteArray();
// Read from storage
ByteBuffer byteBuffer = ByteBuffer.wrap(result);
Model model = Model.getRootAsRepo(byteBuffer);
5. I can now update the views with the Model object
Does this look right? I apologize if this was answered in an earlier post. Can you answer the questions/review inline?