Skip to content

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

Description

@skliarie

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions