Skip to content

Commit dfe68ae

Browse files
Merge pull request #249 from regulaforensics/develop
Develop -> Stable
2 parents b60e98c + 276545d commit dfe68ae

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

regula/documentreader/webclient/ext/api/document_reader_api.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,22 @@ def process(self, process_request: ProcessRequest) -> RecognitionResponse:
3636

3737
def deserialize_to_recognition_response(self, content: Union[bytes, bytearray, str]) -> RecognitionResponse:
3838
response = self.__to_response_object(content)
39-
response = self.api_client.deserialize(response, ProcessResponse)
40-
return RecognitionResponse(response)
39+
40+
if hasattr(response, 'to_str'):
41+
response_text = response.to_str()
42+
elif hasattr(response, 'data'):
43+
data = response.data
44+
if isinstance(data, (bytes, bytearray)):
45+
response_text = data.decode('utf-8')
46+
else:
47+
response_text = str(data)
48+
else:
49+
response_text = str(content) if not isinstance(content, str) else content
50+
51+
content_type = "application/json"
52+
process_response = self.api_client.deserialize(response_text, "ProcessResponse", content_type)
53+
54+
return RecognitionResponse(process_response)
4155

4256
@staticmethod
4357
def __to_response_object(content: Union[bytes, bytearray, str]):

0 commit comments

Comments
 (0)