【发布时间】:2022-01-12 00:54:23
【问题描述】:
截至redis-py4.0,支持json。我在Windows 11 上使用redis-py 版本4.0.2。我有一个使用redislabs/rejson:latest在docker中运行的redis服务器。
我正在尝试通过以下方式加载 json 对象 -
import redis
from redis.commands.json.path import Path
from redis import exceptions
from redis.commands.json.decoders import unstring, decode_list
r = redis.Redis()
d = {"hello": "world", b"some": "value"}
r.json().set("somekey", Path.rootPath(), d)
在测试中它是如何完成的 - https://github.com/redis/redis-py/blob/e8bcdcb97b8c915e2bb52353aeda17c00e1be215/tests/test_json.py#L19
但是我收到了这个错误 -
TypeError: keys must be str, int, float, bool or None, not bytes
我错过了什么?
【问题讨论】: