Creating Nested hash for Python Dictionary


I am experimenting with Python and REDIS a bit and I just had a query with nested JSON object ingestion and extraction part.

Here is my sample JSON blob which i want to insert into REDIS.

obj = {
‘fsname’: ‘fs1’,
‘version’: ‘v1’,
‘record’: [{
‘fname’: ‘abc’,
‘fvalue’: ‘1,2,3,4’
‘fname’: ‘xyz’,
‘fvalue’: ‘5,6,7,8’

I tried to use GitHub - RedisJSON/redisjson-py: An extension to redis-py for using Redis' ReJSON module but somehow not able to even execute the example given there.

Do you have any suggestions on which python client to use to create nested hashes into Redis ? i.e: For the above data i would want to first create a hash with fsname and version as a key. The next level of hash for me was to use fname as key and fvalue as the data.

My query workload would typically be for a fname.

Any inputs would be great!


Hi Rakshith,

Are you running the RedisJSON module on your Redis server? You’ll need that plus the Python client you mentioned to get this to work.


Hi Kyle,

I am running the REDIS server as a docker container and i am trying to utilize the python client outside that environment to connect and carry out CRUD operations via python app (the python app will eventually be dockerized later as a separate Flask app )

Any workaround for my use case?


RedisJSON is as add-on module, and you need that running with your Redis server to use these capabilities.

If you just want to test this out, you can quickly sign up for a free Redis Cloud account:

You can use the RedisJSON docker container which is a Redis container that is already loaded with the RedisJSON module.

docker run -p 6379:6379 --name redis-redisjson redislabs/rejson:latest

@KyleB and @gkorland : I finally was able to get the code working with the docker image you shared above.

Thanks for all the tips!


1 Like