3

Trying to work through setting up ReJSON with Python3. I am running on Ubuntu 16.04 in windows (WSL) and have Redis and ReJSON working.

Have simplified the python in the https://github.com/RedisLabs/rejson-py docs to isolate the problem:

from rejson import Client, Path

rj = Client(host='localhost', port=6379)

obj = {
    'answer': 42,
    'arr': [None, True, 3.14],
    'truth': {
        'coord': 'out there'
    }
}
rj.jsonset('obj', Path.rootPath(), obj)

temp = rj.jsonget('obj', Path('.truth.coord'))

The final line errors with:

TypeError: cannot use a string pattern on a bytes-like object

I know the obj has been written as can be seen in the redis-cli:

127.0.0.1:6379> JSON.GET obj
"{\"answer\":42,\"arr\":[null,true,3.1400000000000001],\"truth\":{\"coord\":\"out there\"}}"

Any Help Appreciated.

0

1 Answer 1

4

Solved. Need to add decode_responses into the client setup:

rj = Client(host='localhost', port=6379, decode_responses=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.