Is it possible to serialize / deserialize flatbuffers to and from JSON?
What I really want to do is to save flatbuffers as JSON, allow people to change whatever value they want, then read back JSON into a flatbuffer (and use that in some way in the application).
Maybe there is another way to achieve the same effect. We are working in C++.
To use FlatBuffers in your code, first generate the C++ classes from your schema with the --cpp option to flatc . Then you can include both FlatBuffers and the generated code to read or write FlatBuffers.
FlatBuffers is a statically typed system, meaning the user of a buffer needs to know what kind of buffer it is. FlatBuffers can of course be wrapped inside other containers where needed, or you can use its union feature to dynamically identify multiple possible sub-objects stored.
Yes, this is built-in functionality in FlatBuffers. See "Text and Schema parsing" here: https://google.github.io/flatbuffers/flatbuffers_guide_use_cpp.html
Also see examples of that in test.cpp
in ParseAndGenerateTextTest()
, or also registry.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With