Using Redis as a JSON Store in Python

Published on 09/18/19 at 13:49 EST by Max Bridgland


Converting this blog to Redis was extremely easy! I was able to simply convert my existing JSON data into Redis JSON objects in under 2 hours. Here is a short tutorial:

import json
import redis

db = redis.StrictRedis(....)

# To Create A JSON Store

>> db.set('key', json.dumps({'test1': 'value1'})
True

# To Grab That JSON Store

>> byte_obj = db.get('key')
>> py_obj = json.loads(byte_obj)
>> print(py_obj)
{'test1': 'value1'}

See how simple it is to use JSON with Redis? I was so happy when I found out :P - Max



Comments: