python - 将具有不可序列化元素的字典转换为字节并返回
问题描述
我必须根据我的项目的需要实施以下方案。
- 我正在从函数中检索字典(其元素不可序列化)
- 我想将上面提到的 dict 转换为字节(所以我可以将它作为对客户端的响应发送回)
- 接下来,我希望客户端(在步骤 2 中)接收到的这些字节通过我的 Web 服务再次发送,并再次转换为其初始格式(dict)。
我尝试使用以下示例从这里开始json.dumps
:
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
hyb_abe.encrypt
函数代码在这里
但我得到
TypeError: Object of type 'Element' is not JSON serializable
我的情况有什么解决方法?
编辑
调试模式下字典值的照片
解决方案
推荐阅读
- sql-server - 创建一个 DW,包括。星模式
- sql - SQL Server:使用此查询获取表达式错误
- sql - 如何在 Snowflake SQL 中的 LEFT JOIN 表上平均每天的聊天数?
- java - 从 CSV 填充对象
- swift - 带参数的 ApplescriptObjC 方法
- java - Android Firebase 查询多个值
- python - 使用自己的名称将 pandas.dataframe 添加到另一个
- haskell - 为什么 extra-lib-dirs 不能像堆栈中的 LD_LIBRARY_PATH 一样工作?
- sql - SQL: IF NULL THEN '-' ,ELSE 条件
- javascript - 使用 RegExp 删除单词