Can I serialize / dserialize flatbuffers to / from JSON?

Ziffusion picture Ziffusion · Jan 11, 2018 · Viewed 9.1k times · Source

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++.

Answer

Aardappel picture Aardappel · Jan 11, 2018

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