Added --defaults-json to output fields at default value.

Normal behavior is to not output fields that happen to have
the default value, since those will be reproduced anyway
when turned into a FlatBuffer binary. This however can be problematic
when using JSON to interop with other system since they might not
know this default value. This flatc option (and also flag
to GenerateText) will force those fields to be output anyway.

Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2015-05-27 16:42:15 -07:00
parent 788acb08d4
commit ecf5a6a580
4 changed files with 44 additions and 25 deletions

View File

@@ -400,6 +400,7 @@ extern void GenComment(const std::vector<std::string> &dc,
// Container of options that may apply to any of the source/text generators.
struct GeneratorOptions {
bool strict_json;
bool output_default_scalars_in_json;
int indent_step;
bool output_enum_identifiers;
bool prefixed_enums;
@@ -411,7 +412,9 @@ struct GeneratorOptions {
Language lang;
GeneratorOptions() : strict_json(false), indent_step(2),
GeneratorOptions() : strict_json(false),
output_default_scalars_in_json(false),
indent_step(2),
output_enum_identifiers(true), prefixed_enums(true),
include_dependence_headers(false),
mutable_buffer(false),