mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-03 12:44:13 +00:00
Fix #2775: Add option to flatc to skip unknown fields in JSON
This commit is contained in:
@@ -100,6 +100,9 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) {
|
|||||||
" no trailing commas in tables/vectors.\n"
|
" no trailing commas in tables/vectors.\n"
|
||||||
" --defaults-json Output fields whose value is the default when\n"
|
" --defaults-json Output fields whose value is the default when\n"
|
||||||
" writing JSON\n"
|
" writing JSON\n"
|
||||||
|
" --unknown-json Allow fields in JSON that are not defined in the\n"
|
||||||
|
" schema. These fields will be discared when generating\n"
|
||||||
|
" binaries.\n"
|
||||||
" --no-prefix Don\'t prefix enum values with the enum type in C++.\n"
|
" --no-prefix Don\'t prefix enum values with the enum type in C++.\n"
|
||||||
" --scoped-enums Use C++11 style scoped and strongly typed enums.\n"
|
" --scoped-enums Use C++11 style scoped and strongly typed enums.\n"
|
||||||
" also implies --no-prefix.\n"
|
" also implies --no-prefix.\n"
|
||||||
@@ -155,6 +158,8 @@ int main(int argc, const char *argv[]) {
|
|||||||
opts.skip_js_exports = true;
|
opts.skip_js_exports = true;
|
||||||
} else if(arg == "--defaults-json") {
|
} else if(arg == "--defaults-json") {
|
||||||
opts.output_default_scalars_in_json = true;
|
opts.output_default_scalars_in_json = true;
|
||||||
|
} else if (arg == "--unknown-json") {
|
||||||
|
opts.skip_unexpected_fields_in_json = true;
|
||||||
} else if(arg == "--no-prefix") {
|
} else if(arg == "--no-prefix") {
|
||||||
opts.prefixed_enums = false;
|
opts.prefixed_enums = false;
|
||||||
} else if(arg == "--scoped-enums") {
|
} else if(arg == "--scoped-enums") {
|
||||||
|
|||||||
Reference in New Issue
Block a user