0

i have a method that does some calculations and must return a dictionary as shown below in the code section. the method can not return the dictionary as it contains non serialized data. i tried to enocod it as explained in the link below https://pynative.com/online-python-code-editor-to-execute-python-code/ and her as well TypeError: Object of type 'float32' is not JSON serializable

but i still receive the same error message. please let me know how to solve this issue

code:

resultsDict = {
    "pixelsValuesSatisfyThresholdInWindowSegment":json.dumps(numpyData,cls=NumpyArrayEncoder),
    ...
    ...
    ...
}
return resultsDict

error message

raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type float32 is not JSON serializable
Amrmsmb
  • 1
  • 27
  • 104
  • 226

1 Answers1

0

I just did the following

resultsDict = 
 {"pixelsValuesSatisfyThresholdInWindowSegment":str(pixelsValuesSatisfyThresholdInWindowSegment)
}

and it is working.

Amrmsmb
  • 1
  • 27
  • 104
  • 226