mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 08:41:36 +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;
|
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 "[]".
|
// Print a vector a sequence of JSON values, comma separated, wrapped in "[]".
|
||||||
|
|||||||
@@ -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];
|
||||||
|
|||||||
Reference in New Issue
Block a user