Commit 5de28c74 authored by Björn Reimer's avatar Björn Reimer Committed by Wouter van Oortmerssen

serialize boolean in JSON to "true/false" instead of "0/1"

Change-Id: I90cf519c00eaf9ccd9fcab8035a91b9205587c3b
parent 44261ccd
...@@ -60,7 +60,12 @@ template<typename T> void Print(T val, Type type, int /*indent*/, ...@@ -60,7 +60,12 @@ template<typename T> void Print(T val, Type type, int /*indent*/,
return; return;
} }
} }
if (type.base_type == BASE_TYPE_BOOL) {
text += val ? "true" : "false";
} else {
text += NumToString(val); text += NumToString(val);
}
} }
// Print a vector a sequence of JSON values, comma separated, wrapped in "[]". // Print a vector a sequence of JSON values, comma separated, wrapped in "[]".
......
...@@ -635,6 +635,11 @@ void FuzzTest2() { ...@@ -635,6 +635,11 @@ void FuzzTest2() {
Dummy(); Dummy();
} }
break; break;
case flatbuffers::BASE_TYPE_BOOL:
AddToSchemaAndInstances("bool", deprecated
? ""
: (lcg_rand() % 2 ? "true" : "false"));
break;
default: default:
// All the scalar types. // All the scalar types.
schema += flatbuffers::kTypeNames[base_type]; schema += flatbuffers::kTypeNames[base_type];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment