Registry / database / rejson

rejson

JSON →
library0.5.6pypypiunverified

rejson-py is a Python client library for RedisJSON, a Redis module that implements the JSON data type. It provides an extended interface to redis-py, offering on-the-fly serialization and deserialization of JSON objects. As of `redis-py` version 4.0.0, this library is deprecated, and its functionalities have been integrated directly into the `redis-py` client. The `rejson` package is currently at version 0.5.6 and has a very slow release cadence, with the last update in November 2021.

pip install rejson
INSTALL
IMPORT
SIG · REJSON
R
rejson
databasepythonv0.5.6
Install
1.8s avg
Import
1034ms
Disk
69MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 0.679s · 70.8MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 1.8s · import 0.562s · 20MB
69MB installed
● package 69MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from rejson import Client
from rejson import Client

This quickstart demonstrates basic operations (set, get, update, append) using the `rejson-py` client. It requires a running Redis server with the RedisJSON module loaded. A commented-out section shows the equivalent approach using the recommended `redis-py` client (v4.0.0+).

import os from rejson import Client, Path import json # Ensure a RedisJSON server is running, e.g., via Docker: # docker run -d -p 6379:6379 redislabs/rejson:latest REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost') REDIS_PORT = int(os.environ.get('REDIS_PORT', 6379)) try: # Using the deprecated rejson-py client rj = Client(host=REDIS_HOST, port=REDIS_PORT) obj = { 'name': 'Alice', 'age': 30, 'city': 'New York', 'hobbies': ['reading', 'hiking'], 'address': {'street': '123 Main St', 'zip': '10001'} } # Set a JSON object at the root path rj.jsonset('user:1', Path.rootPath(), obj) print(f"Set JSON for user:1: {obj}") # Get a specific field name = rj.jsonget('user:1', Path('.name')) print(f"User's name: {name}") # Update a field rj.jsonset('user:1', Path('.age'), 31) updated_age = rj.jsonget('user:1', Path('.age')) print(f"Updated user's age: {updated_age}") # Append to an array rj.jsonarrappend('user:1', Path('.hobbies'), 'coding') hobbies = rj.jsonget('user:1', Path('.hobbies')) print(f"User's hobbies after appending: {hobbies}") # --- Recommended modern approach using redis-py (v4.0.0+) --- # from redis import Redis # r = Redis(host=REDIS_HOST, port=REDIS_PORT) # r.json().set('user:2', Path.root_path(), {'email': 'bob@example.com'}) # email = r.json().get('user:2', Path('.email')) # print(f"User 2 email (via redis-py): {email}") except Exception as e: print(f"An error occurred: {e}") print("Please ensure a Redis server with the ReJSON module is running and accessible.")
Debug
Known issues
breakingThe `rejson-py` library is deprecated since `redis-py` version 4.0.0. All its features for interacting with RedisJSON have been merged into the official `redis-py` client.
fix
Migrate your code to use the `redis.Redis().json()` interface from the `redis` library. This is the recommended and actively maintained way to interact with RedisJSON from Python. For example, instead of `rj.jsonset('key', Path.rootPath(), data)`, use `r.json().set('key', Path.root_path(), data)`.
affects: rejson-py all versions, redis-py >=4.0.0
gotcha`rejson-py` (and the `redis-py` JSON client) requires a Redis server with the RedisJSON module specifically loaded. Installing the Python client alone is not enough; the Redis server must be configured with the module.
fix
Ensure your Redis server instance has the RedisJSON module loaded. This can typically be done via Docker (`docker run -p 6379:6379 redislabs/rejson:latest`) or by adding `loadmodule /path/to/rejson.so` to your `redis.conf` and restarting Redis.
affects: All versions of rejson-py and RedisJSON
breakingRedisJSON server module (v2.6.9+) changed the default JSONPath root from `$` to `.` under RESP3. While `rejson-py` abstracts some of this, direct path usage might be affected.
fix
Explicitly specify the root path in your JSONPath expressions (e.g., `Path.rootPath()` or `Path('.')`) to avoid ambiguity, especially if interacting with different RedisJSON server versions or using RESP3.
affects: RedisJSON module >=2.6.9
Upgrade
Version history
0.5.6latest on PyPI · released Nov 18, 2021
Audit
Dependencies
redisrequiredrejson-py extends the redis-py client.
Agent activity
22 hits · last 30 days
node
20
Resources
rejson — pip install rejson · libregistry