Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I serialize / dserialize flatbuffers to / from JSON?

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

like image 894
Ziffusion Avatar asked Jan 11 '18 21:01

Ziffusion


People also ask

How do you use Flatbuffer 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.

How do FlatBuffers work?

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.


1 Answers

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

like image 106
Aardappel Avatar answered Sep 30 '22 10:09

Aardappel