Question: Can Redis Store JSON?


Yes. The RedisJSON module provides JSON support for Redis. RedisJSON enables you store, update, and load JSON values in a Redis database, similar to any other Redis data type. 

Primary Features

  • Full support for the JSON standard.
  • Documents stored as binary data in a tree structure, allowing fast access to sub-elements.
  • Typed atomic operations for all JSON value types.

Python Example

The code snippet below shows how to use RedisJSON with raw Redis commands from Python with redis-py:

import redis data = {    'dog': {        'scientific-name' : 'Canis familiaris'    } } r = redis.Redis() r.json().set('doc', '$', data) doc = r.json().get('doc', '$') dog = r.json().get('doc', '$.dog') scientific_name = r.json().get('doc', '$..scientific-name')

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.