Skip to content

Commit 40aa964

Browse files
authored
Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API (google#7713)
* Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API * Append Bytes to AsStringBytes return value Co-authored-by: Jared Junyoung Lim <jaredlim@google.com>
1 parent e1a2f68 commit 40aa964

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎python/flatbuffers/flexbuffers.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,15 @@ def AsKey(self):
727727
def IsString(self):
728728
return self._type is Type.STRING
729729

730+
@property
731+
def AsStringBytes(self):
732+
if self.IsString:
733+
return String(self._Indirect(), self._byte_width).Bytes
734+
elif self.IsKey:
735+
return self.AsKeyBytes
736+
else:
737+
raise self._ConvertError(Type.STRING)
738+
730739
@property
731740
def AsString(self):
732741
if self.IsString:

0 commit comments

Comments
 (0)