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

Change-Id: I90cf519c00eaf9ccd9fcab8035a91b9205587c3b
This commit is contained in:
Björn Reimer
2015-09-08 11:00:35 +02:00
committed by Wouter van Oortmerssen
parent 44261ccdf1
commit 5de28c74f9
2 changed files with 11 additions and 1 deletions

View File

@@ -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 "[]".

View File

@@ -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];