mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
serialize boolean in JSON to "true/false" instead of "0/1"
Change-Id: I90cf519c00eaf9ccd9fcab8035a91b9205587c3b
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
44261ccdf1
commit
5de28c74f9
@@ -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 "[]".
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user