Search code examples
c++jsonserializationflatbuffers

Flatbuffers usage


I’m kind of confused how flat buffers work.

I tried looking at the docs but am still confused.

Basically, what I need to do is

  • Load JSON data (or actually, ANY data format as long as it’s changeable by another user and readable) from a file into a struct or read the fields one by one.
  • Save the struct back into any readable data format as a file once the app closes

That’s why I’m confused on flatbuffers. How do you change the file once it’s saved? Is the saved result binary? Or is that not what it was built for?

I’m using RapidJson currently.

The usage is read text data into a struct, when app ends save struct into text that’s modifiable.


Solution

  • Flatbuffers are a compact binary representation of a given data structure, with the promise that it can be used "straight from the wire", without any deserialization after the fact. By contrast, protocol buffers fill the same niche but need to be (de)serialized.

    For your purposes, just stick with JSON or YAML, since "readable by humans" is a priority.