We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 035793a commit eb5020dCopy full SHA for eb5020d
betterproto/__init__.py
@@ -595,6 +595,9 @@ def _postprocess_single(
595
elif meta.proto_type in [TYPE_SINT32, TYPE_SINT64]:
596
# Undo zig-zag encoding
597
value = (value >> 1) ^ (-(value & 1))
598
+ elif meta.proto_type == TYPE_BOOL:
599
+ # Booleans use a varint encoding, so convert it to true/false.
600
+ value = value > 0
601
elif wire_type in [WIRE_FIXED_32, WIRE_FIXED_64]:
602
fmt = _pack_fmt(meta.proto_type)
603
value = struct.unpack(fmt, value)[0]
betterproto/tests/bool.json
@@ -0,0 +1,3 @@
1
+{
2
+ "value": true
3
+}
betterproto/tests/bool.proto
@@ -0,0 +1,5 @@
+syntax = "proto3";
+
+message Test {
4
+ bool value = 1;
5
0 commit comments