mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 05:47:36 +00:00
Add --force-empty-vectors option (#5653)
The rationale for this option is that JSON clients typically want empty arrays (i.e [] in the JSON) instead of missing properties, but not empty strings when the value isn't set. --force-empty is kept as-is, i.e. it will force both empty strings and vectors. Closes #5652
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
d7530ae961
commit
a8e800bd7c
@@ -588,9 +588,13 @@ struct IDLOptions {
|
||||
// for code generation.
|
||||
unsigned long lang_to_generate;
|
||||
|
||||
// If set (default behavior), empty string and vector fields will be set to
|
||||
// nullptr to make the flatbuffer more compact.
|
||||
bool set_empty_to_null;
|
||||
// If set (default behavior), empty string fields will be set to nullptr to make
|
||||
// the flatbuffer more compact.
|
||||
bool set_empty_strings_to_null;
|
||||
|
||||
// If set (default behavior), empty vector fields will be set to nullptr to make
|
||||
// the flatbuffer more compact.
|
||||
bool set_empty_vectors_to_null;
|
||||
|
||||
IDLOptions()
|
||||
: use_flexbuffers(false),
|
||||
@@ -635,7 +639,8 @@ struct IDLOptions {
|
||||
lang(IDLOptions::kJava),
|
||||
mini_reflect(IDLOptions::kNone),
|
||||
lang_to_generate(0),
|
||||
set_empty_to_null(true) {}
|
||||
set_empty_strings_to_null(true),
|
||||
set_empty_vectors_to_null(true) {}
|
||||
};
|
||||
|
||||
// This encapsulates where the parser is in the current source file.
|
||||
|
||||
Reference in New Issue
Block a user