Question: Can Redis Store JSON?
Answer
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?
Other Common Redis Questions (and Answers)
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.
Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost