NickAth
NickAth

Reputation: 1112

Convert a dictionary with non serializable elements into bytes and back

I have to implement the following scenario for the needs of my project.

  1. I am retrieving a dict from a function (whose elements are not serializable)
  2. I want to convert the above mentioned dict into bytes (so I can send it back as a response to the client)
  3. 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

enter image description here

Upvotes: 0

Views: 94

Answers (0)

Related Questions