{"id":26022303,"url":"https://github.com/RedisJSON/redisjson-py","last_synced_at":"2025-03-06T09:54:56.907Z","repository":{"id":44895182,"uuid":"90918056","full_name":"RedisJSON/redisjson-py","owner":"RedisJSON","description":"An extension to redis-py for using Redis' ReJSON module","archived":false,"fork":false,"pushed_at":"2023-02-08T08:30:24.000Z","size":120,"stargazers_count":160,"open_issues_count":16,"forks_count":34,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-02T04:08:58.227Z","etag":null,"topics":["json","python","redis","rejson"],"latest_commit_sha":null,"homepage":"https://redisjson.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedisJSON.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-10T23:48:14.000Z","updated_at":"2024-09-01T14:28:52.000Z","dependencies_parsed_at":"2024-06-18T12:39:54.344Z","dependency_job_id":"521c78fb-27b4-4c81-af29-360f39d73c48","html_url":"https://github.com/RedisJSON/redisjson-py","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisJSON%2Fredisjson-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisJSON%2Fredisjson-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisJSON%2Fredisjson-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisJSON%2Fredisjson-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedisJSON","download_url":"https://codeload.github.com/RedisJSON/redisjson-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242187659,"owners_count":20086218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","python","redis","rejson"],"created_at":"2025-03-06T09:54:54.194Z","updated_at":"2025-03-06T09:54:56.882Z","avatar_url":"https://github.com/RedisJSON.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![license](https://img.shields.io/github/license/RedisJSON/RedisJSON-py.svg)](https://github.com/RedisJSON/redisjson-py/blob/master/LICENSE)\n[![pypi](https://badge.fury.io/py/rejson.svg)](https://badge.fury.io/py/rejson)\n[![PyVersions](https://img.shields.io/pypi/pyversions/rejson.svg)](https://github.com/RedisJSON/redisjson-py)\n[![GitHub issues](https://img.shields.io/github/release/RedisJSON/redisjson-py.svg)](https://github.com/RedisJSON/redisjson-py/releases/latest)\n[![Codecov](https://coveralls.io/repos/github/RedisLabs/rejson-py/badge.svg?branch=master)](https://coveralls.io/github/RedisLabs/rejson-py?branch=master)\n[![Known Vulnerabilities](https://snyk.io/test/github/RedisJSON/redisjson-py/badge.svg?targetFile=pyproject.toml)](https://snyk.io/test/github/RedisJSON/redisjson-py?targetFile=pyproject.toml)\n\n# RedisJSON Python Client\n\n[![Forum](https://img.shields.io/badge/Forum-RedisJSON-blue)](https://forum.redislabs.com/c/modules/redisjson)\n[![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/QUkjSsk)\n\n## Deprecation notice\n\nAs of [redis-py 4.0.0](https://pypi.org/project/redis/4.0.0) this library is deprecated. It's features have been merged into redis-py. Please either install it [from pypy](https://pypi.org/project/redis) or [the repo](https://github.com/redis/redis-py).\n\n--------------------------------\n\nrejson-py is a package that allows storing, updating and querying objects as\nJSON documents in a [Redis](https://redis.io) database that is extended with the\n[ReJSON module](https://github.com/redislabsmodules/rejson). The package extends\n[redis-py](https://github.com/andymccurdy/redis-py)'s interface with ReJSON's\nAPI, and performs on-the-fly serialization/deserialization of objects to/from\nJSON.\n\n## Installation\n\n```bash\n$ pip install rejson\n```\n\n## Development\n\n1. Create a virtualenv to manage your python dependencies, and ensure it's active.\n   ```virtualenv -v venv```\n2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies.\n   ```pip install --user poetry```\n3. Install dependencies.\n   ```poetry install```\n\n[tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded.\n\n## Usage example\n\n```python\n   from rejson import Client, Path\n\n   rj = Client(host='localhost', port=6379, decode_responses=True)\n\n   # Set the key `obj` to some object\n   obj = {\n       'answer': 42,\n       'arr': [None, True, 3.14],\n       'truth': {\n           'coord': 'out there'\n       }\n   }\n   rj.jsonset('obj', Path.rootPath(), obj)\n\n   # Get something\n   print 'Is there anybody... {}?'.format(\n       rj.jsonget('obj', Path('.truth.coord'))\n   )\n\n   # Delete something (or perhaps nothing), append something and pop it\n   rj.jsondel('obj', Path('.arr[0]'))\n   rj.jsonarrappend('obj', Path('.arr'), 'something')\n   print '{} popped!'.format(rj.jsonarrpop('obj', Path('.arr')))\n\n   # Update something else\n   rj.jsonset('obj', Path('.answer'), 2.17)\n\n   # And use just like the regular redis-py client\n   jp = rj.pipeline()\n   jp.set('foo', 'bar')\n   jp.jsonset('baz', Path.rootPath(), 'qaz')\n   jp.execute()\n\n   # If you use non-ascii character in your JSON data, you can add the no_escape flag to JSON.GET command\n   obj_non_ascii = {\n     'non_ascii_string': 'hyvää'\n   }\n   rj.jsonset('non-ascii', Path.rootPath(), obj_non_ascii)\n   print '{} is a non-ascii string'.format(rj.jsonget('non-ascii', Path('.non_ascii_string'), no_escape=True))\n```\n\n## Encoding/Decoding\n\nrejson-py uses Python's [json](https://docs.python.org/2/library/json.html).\nThe client can be set to use custom encoders/decoders at creation, or by calling\nexplicitly the [setEncoder()](./API.md#setencoder) and\n[setDecoder()](./API.md#setencoder) methods, respectively.\n\nThe following shows how to use this for a custom class that's stored as\na JSON string for example:\n\n```python\n\n   from json import JSONEncoder, JSONDecoder\n   from rejson import Client\n\n   class CustomClass(object):\n       \"Some non-JSON-serializable\"\n       def __init__(self, s=None):\n           if s is not None:\n               # deserialize the instance from the serialization\n               if s.startswith('CustomClass:'):\n                   ...\n               else:\n                   raise Exception('unknown format')\n           else:\n               # initialize the instance\n               ...\n\n       def __str__(self):\n           _str = 'CustomClass:'\n           # append the instance's state to the serialization\n           ...\n           return _str\n\n       ...\n\n   class CustomEncoder(JSONEncoder):\n       \"A custom encoder for the custom class\"\n       def default(self, obj):\n           if isinstance(obj, CustomClass):\n               return str(obj)\n           return json.JSONEncoder.encode(self, obj)\n\n   class TestDecoder(JSONDecoder):\n       \"A custom decoder for the custom class\"\n       def decode(self, obj):\n           d = json.JSONDecoder.decode(self, obj)\n           if isinstance(d, basestring) and d.startswith('CustomClass:'):\n               return CustomClass(d)\n           return d\n\n   # Create a new instance of CustomClass\n   obj = CustomClass()\n\n   # Create a new client with the custom encoder and decoder\n   rj = Client(encoder=CustomEncoder(), decoder=CustomDecoder())\n\n   # Store the object\n   rj.jsonset('custom', Path.rootPath(), obj))\n\n   # Retrieve it\n   obj = rj.jsonget('custom', Path.rootPath())\n```\n\n## API\n\nAs rejson-py exposes the same methods as redis-py, it can be used as a drop-in\nreplacement. On top of Redis' core commands, the client also adds ReJSON's\nvocabulary and a couple of helper methods. These are documented in the\n[API.md](API.md) file, which can be generated by running:\n\n```bash\n$ python gendoc rejson \u003e API.md\n```\n\nFor complete documentation about ReJSON's commands, refer to [ReJSON's website](http://rejson.io).\n\n## License\n\n[BSD 2-Clause](https://github.com/RedisLabs/rejson-py/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRedisJSON%2Fredisjson-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRedisJSON%2Fredisjson-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRedisJSON%2Fredisjson-py/lists"}