Parse Binary schemas in C++

166 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Yasaswi K

ungelesen,
20.10.2017, 12:54:3920.10.17
an 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

ungelesen,
20.10.2017, 13:33:1620.10.17
an 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

ungelesen,
11.11.2017, 04:17:0411.11.17
an 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.

Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten