I have to implement the following scenario for the needs of my project.
- I am retrieving a dict from a function (whose elements are not serializable)
- I want to convert the above mentioned dict into bytes (so I can send it back as a response to the client)
- Next, I want these bytes received by the client (in step 2) to be sent again through my web service, and convert again to its initial format (dict).
I tried to follow the example from here by using json.dumps
as follows:
cipher_text = hyb_abe.encrypt(master_public_key, fileInBase64Format, policy) #this function comes from the charm-crypto framework and returns a dictionary
encrypted_bytes = json.dumps(cipher_text) # produces error TypeError: Object of type 'Element' is not JSON serializable
The code of hyb_abe.encrypt
function is here
but I am getting
TypeError: Object of type 'Element' is not JSON serializable
What could be a workaround for my case?
EDIT
Photo of the value of the dictionary in debug mode