Skip to content

Commit f243109

Browse files
committed
Fix google#2775: Add option to flatc to skip unknown fields in JSON
1 parent 13d0594 commit f243109

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/flatc.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) {
100100
" no trailing commas in tables/vectors.\n"
101101
" --defaults-json Output fields whose value is the default when\n"
102102
" writing JSON\n"
103+
" --unknown-json Allow fields in JSON that are not defined in the\n"
104+
" schema. These fields will be discared when generating\n"
105+
" binaries.\n"
103106
" --no-prefix Don\'t prefix enum values with the enum type in C++.\n"
104107
" --scoped-enums Use C++11 style scoped and strongly typed enums.\n"
105108
" also implies --no-prefix.\n"
106109
" --gen-includes (deprecated), this is the default behavior.\n"
107110
" If the original behavior is required (no include\n"
108-
" statements) use --no-includes.\n"
111+
" statements) use --no-includes.\n"
109112
" --no-includes Don\'t generate include statements for included\n"
110113
" schemas the generated file depends on (C++).\n"
111114
" --gen-mutable Generate accessors that can mutate buffers in-place.\n"
@@ -155,6 +158,8 @@ int main(int argc, const char *argv[]) {
155158
opts.skip_js_exports = true;
156159
} else if(arg == "--defaults-json") {
157160
opts.output_default_scalars_in_json = true;
161+
} else if (arg == "--unknown-json") {
162+
opts.skip_unexpected_fields_in_json = true;
158163
} else if(arg == "--no-prefix") {
159164
opts.prefixed_enums = false;
160165
} else if(arg == "--scoped-enums") {

0 commit comments

Comments
 (0)