Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Queries on schema and JSON data conversion #6442

Locked Unanswered
blueshift155 asked this question in Q&A
Discussion options

We already have flatbuffer library embedded in our software code for simple schemas with JSON output data generation.

Now we also need to have the following schema tree to be supported.

namespace SampleNS;
/// user defined key value pairs to add custom metadata
/// key namespacing is the responsibility of the user
table KeyValue {
 key:string (key, required); 
 value:string (required);
}
enum SchemaVersion:byte {
 V1,
 V2
}
table Sometable {
 value1:ubyte;
 value2:ushort (key);
}
table ComponentData {
 inputs: [Sometable];
 outputs: [Sometable];
}
table Node {
 name:string (key);
 
 /// IO definition
 data:ComponentData;
 
 /// nested child
 child:[Components];
}
table Components {
 type:ubyte;
 index:ubyte;
 nodes:[Node];
}
table GroupMasterData {
 schemaversion:SchemaVersion = sampleNS::SchemaVersion::V1;
 metainfo:[KeyValue];
 /// List of expected components in the system
 components:[Components];
}
root_type GroupMasterData;

As from above, table Components is nested recursively. The intention is components may have childs that have the same fields.

I have few queries:

  • Flatc didnt gave me any error during schema compilation for such
    recursive nested tables. But is this supported during the field
    access for such tables?
  • I tried to generate a sample json data file based on above data but I
    could not see the field for schemaversion. I learned FB doesn't
    serialize the default values. so, I removed the default value that I
    assigned in the schema. But, it still doesnt write into the json data
    file. On this I also learned we can forcefully write into the file
    using force_defaults option. I don't know where is this is to be
    put: in the attribute or elsewhere?
  • Can I create a struct of enum field?
You must be logged in to vote

Replies: 1 comment

Comment options

Ok, this is the 3rd place you've posted this, after Stack Overflow (where it was answered) and the mailing list. Do you consider other people's time when doing this kind of cross-posting?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /