Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not load json: AttributeError: 'str' object has no attribute 'items' #68

Open
skliarie opened this issue Jan 21, 2024 · 0 comments
Open

Comments

@skliarie
Copy link

skliarie commented Jan 21, 2024

python3 --version

Python 3.10.12

pip3 install python-redis

...
Created wheel for python-redis: filename=python_redis-0.4.0-py2.py3-none-any.whl size=20546 sha256=7f032eb61d2b09e6c59065016b656f0522872722f9f63858e9e29e92e6ee0af8

The error

I mare redis-dump using redisdl.py like this:
./redisdl.py -H $redis_host -d 0 -E iso-8859-1 > /tmp/redis.json

Then I tried to load it and it failed with error. Here is the offending key:

# cat a.json 
{
  "GWPA:LDR:10015:event:103874": {
    "type": "zset",
    "value": [
      [
        "0",
        0.0
      ]
    ]
  }
}
# cat a.json | ./redisdl.py -l -H $redis_host -d 0 -E iso-8859-1 --empty
Traceback (most recent call last):
  File "/tmp/./redisdl.py", line 632, in <module>
    main()
  File "/tmp/./redisdl.py", line 628, in main
    do_load(options, args)
  File "/tmp/./redisdl.py", line 556, in do_load
    load(input, **kwargs)
  File "/tmp/./redisdl.py", line 466, in load
    load_lump(fp, host=host, port=port, password=password, db=db,
  File "/tmp/./redisdl.py", line 347, in load_lump
    loads(s, host, port, password, db, empty, unix_socket_path, encoding, use_expireat=use_expireat)
  File "/tmp/./redisdl.py", line 328, in loads
    _writer(r, p, key, type, value, ttl, expireat, use_expireat=use_expireat)
  File "/tmp/./redisdl.py", line 483, in _writer
    p.zadd(key, element, score)
  File "/usr/local/lib/python3.10/dist-packages/redis/commands/core.py", line 4167, in zadd
    for pair in mapping.items():
AttributeError: 'str' object has no attribute 'items'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant