Parse Binary schemas in C++

167 views
Skip to first unread message

Yasaswi K

unread,
Oct 20, 2017, 12:54:39 PM10/20/17
to FlatBuffers
I have a use case where I need to convert from JSON to Flatbuffer and Flatbuffer to JSON as well. However I only have the binary schema files (bfbs) files available in my environment. Currently Parser::Parse() can only parse regular schema files (fbs).
I see an issue open for this functionality (#4178). Is this feature a priority/being carried out currently by anybody?
Any ideas/suggestions for any possible workarounds to deserialize a binary schema to its schema?

Wouter van Oortmerssen

unread,
Oct 20, 2017, 1:33:16 PM10/20/17
to Yasaswi K, FlatBuffers
I don't think there's currently anyone working on this functionality, no.

It shouldn't be that hard.. it be a question of writing code that does the reverse of what the Serialize methods at the end of idl_parser.cpp are doing.

Note that for converting to JSON, we nowadays also have FlatBufferToString in minireflect.h. However parsing JSON there is only one option, which needs the original text schema file or code for deserializing a binary schema.

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mikkelfj

unread,
Nov 11, 2017, 4:17:04 AM11/11/17
to FlatBuffers


On Friday, October 20, 2017 at 6:54:39 PM UTC+2, Yasaswi K wrote:
Any ideas/suggestions for any possible workarounds to deserialize a binary schema to its schema?

The following C project reads a binary file and produces a JSON dump of the schema. The JSON is arbitrary and just to illustrate have to process a bfbs file.
You might be able to adapt the source to generate text schema files instead.
Note that the binary schema does not contain all the original schema information, but it might be good enough for your purpose. 
If you prefer to work in C++, you could still follow the structure of the example for inspiration.

Reply all
Reply to author
Forward
0 new messages