diff --git a/src/idl_gen_text.cpp b/src/idl_gen_text.cpp index e26d93ca52c1d8db9e4819047d21af17313f5472..52987af2355692c11ad22c069b0f5fd7fd917d18 100644 --- a/src/idl_gen_text.cpp +++ b/src/idl_gen_text.cpp @@ -60,7 +60,12 @@ template<typename T> void Print(T val, Type type, int /*indent*/, return; } } - text += NumToString(val); + + if (type.base_type == BASE_TYPE_BOOL) { + text += val ? "true" : "false"; + } else { + text += NumToString(val); + } } // Print a vector a sequence of JSON values, comma separated, wrapped in "[]". diff --git a/tests/test.cpp b/tests/test.cpp index 116068edddbfd4fb2c80d04974e4d898b4b5dd64..be008180eb224cac58d643fc0e1ed08ee3255692 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -635,6 +635,11 @@ void FuzzTest2() { Dummy(); } break; + case flatbuffers::BASE_TYPE_BOOL: + AddToSchemaAndInstances("bool", deprecated + ? "" + : (lcg_rand() % 2 ? "true" : "false")); + break; default: // All the scalar types. schema += flatbuffers::kTypeNames[base_type];