-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Queries on schema and JSON data conversion #6442
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment