{"id":17592560,"url":"https://github.com/kromdaniel/rejonson","last_synced_at":"2026-03-01T13:34:52.226Z","repository":{"id":57491311,"uuid":"134048549","full_name":"KromDaniel/rejonson","owner":"KromDaniel","description":"Golang Redis Rejson extension built upon go-redis","archived":false,"fork":false,"pushed_at":"2023-02-20T05:34:21.000Z","size":57,"stargazers_count":29,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T12:11:59.588Z","etag":null,"topics":["go","go-redis","golang","json","redis","rejson"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KromDaniel.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-05-19T09:33:23.000Z","updated_at":"2023-08-30T05:58:19.000Z","dependencies_parsed_at":"2024-06-18T22:53:13.975Z","dependency_job_id":"201c63b3-0350-438d-8100-f091d93b8f7e","html_url":"https://github.com/KromDaniel/rejonson","commit_stats":{"total_commits":26,"total_committers":4,"mean_commits":6.5,"dds":"0.34615384615384615","last_synced_commit":"9a8bd082bf18bcf3001be8286db87e6e8b8ffebb"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KromDaniel%2Frejonson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KromDaniel%2Frejonson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KromDaniel%2Frejonson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KromDaniel%2Frejonson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KromDaniel","download_url":"https://codeload.github.com/KromDaniel/rejonson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251538892,"owners_count":21605600,"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":["go","go-redis","golang","json","redis","rejson"],"created_at":"2024-10-22T05:23:48.713Z","updated_at":"2026-03-01T13:34:52.181Z","avatar_url":"https://github.com/KromDaniel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rejonson\n\nRedis rejson extension built upon [go-redis](https://github.com/go-redis/redis)\n\n[![Build Status](https://travis-ci.org/KromDaniel/rejonson.svg?branch=master)](https://travis-ci.org/KromDaniel/rejonson)\n[![Coverage Status](https://coveralls.io/repos/github/KromDaniel/rejonson/badge.svg?branch=master)](https://coveralls.io/github/KromDaniel/rejonson?branch=master)\n\n## Table of Contents\n\n1. [Quick start](#Quick%20Start)\n2. [API](#api)\n3. [Dependencies](#dependencies)\n4. [Testing](#testing)\n5. [License](#license)\n6. [Contact](#contact)\n \n\n## Quick start\n\n### Install\n\n\n#### go-redis v6\n```shell\ngo get github.com/KromDaniel/rejonson\n```\n\n#### go-redis v7\n```shell\ngo get github.com/KromDaniel/rejonson/v7\n```\n\n#### go-redis v8\n```shell\ngo get github.com/KromDaniel/rejonson/v8\n```\n#### go-redis v9\n```shell\ngo get github.com/KromDaniel/rejonson/v9\n```\n\n## Quick Start\n\n\n```go\nimport (\n\t\"github.com/KromDaniel/rejonson\"\n\t\"github.com/go-redis/redis\"\n)\n\nfunc FunctionalApi(client *redis.Client) {\n  // all rejonson.JsonX functions accepts redis.Client or redis.Pipeline\n\t// notice that some versions of go-redis also require context.Context (which is supported by rejonson)\n\tjsonStringCmd := rejonson.JsonGet(client, \"key\")\n\tif err := jsonStringCmd.Err(); err != nil {\n\t\tpanic(err)\n\t}\n\n\tpipeline := client.Pipeline()\n\trejonson.JsonGet(pipeline, \"key\")\n\tcmds, err := pipeline.Exec()\n\t// do something with cmds, err\n}\n\nfunc ExtendClient(client *redis.Client) *rejonson.Client {\n  // You can extend go-redis client to rejonson.Client\n  // that will have all JSON API as methods\n\trejonsonClient := rejonson.ExtendClient(client)\n\tpingCmd := rejonsonClient.Ping()\n\tjsonCmd := rejonsonClient.JsonDel(\"key\")\n\n\treturn rejonsonClient\n}\n```\n\n### Functional API\nRejonson exports Json`X` functions, all of them accept `RedisProcessor` as first parameter and `context.Context` (for go-redis versions \u003e= 8) as second parameter, the other parameters are command specific\n\n\n#### RedisProcessor\nRedisProcessor is `interface` with the following definition:\n\n```go\ntype RedisProcessor interface {\n\tProcess(redis.Cmder) error\n}\n```\n#### go-redis \u003e= 8\n```go\ntype RedisProcessor interface {\n\tProcess(context.Context, redis.Cmder) error\n}\n```\n\nBy default all `*redis.Client`, `redis.Pipeliner`, `*redis.ClusterClient`, `*redis.SentinelClient` implenets that interface, so you can pass any of them to the rejonson functional API\n\n#### example\n```go\nclient := redis.NewClient(\u0026redis.Options{ /*...*/ })\n\nres := rejonson.JsonMGet(client, \"key1\", \"key2\", \"$..a\")\nif res.Err() != nil {\n\t// handle error\n}\n\nfor _, value := range res.Val() {\n\t// do something with value\n}\n```\n\n### Extend Client \nExtends [go-redis](https://github.com/go-redis/redis) client with all ReJSON abilities, so you can use directly the rejson client for all redis usage and commands.\n\n```go\n// go redis client\ngoRedisClient := redis.NewClient(\u0026redis.Options{\n  Addr: \"localhost:6379\",\n})\n\nclient := rejonson.ExtendClient(goRedisClient)\ndefer client.Close()\n\narr := []interface{}{\"hello\", \"world\", 1, map[string]interface{}{\"key\": 12}}\njs, err := json.Marshal(arr)\nif err != nil {\n  // handle\n}\n// redis \"native\" command\nclient.Set(\"go-redis-cmd\", \"hello\", time.Second)\n// rejson command\nclient.JsonSet(\"rejson-cmd\", \".\", string(js))\n\n// int command\narrLen, err := client.JsonArrLen(\"rejson-cmd\", \".\").Result()\nif err != nil {\n  // handle\n}\n\nfmt.Printf(\"Array length: %d\", arrLen)\n// Output: Array length: 4\n```\n\n### Pipeline\nClient will also return extended `Pipeline` and `TXPipeline`\n\n```go\ngoRedisClient := redis.NewClient(\u0026redis.Options{\n  Addr: \"localhost:6379\",\n})\n\nclient := rejonson.ExtendClient(goRedisClient)\n\npipeline := client.Pipeline()\npipeline.JsonSet(\"rejson-cmd-pipeline\", \".\", \"[10]\")\npipeline.JsonNumMultBy(\"rejson-cmd-pipeline\", \"[0]\", 10)\npipeline.Set(\"go-redis-pipeline-command\", \"hello from go-redis\", time.Second)\n\n_, err := pipeline.Exec()\nif err != nil {\n  // handle error\n}\njsonString, err := client.JsonGet(\"rejson-cmd-pipeline\").Result()\nif err != nil {\n  // handle error\n}\n\nfmt.Printf(\"Array %s\", jsonString)\n\n// Output: Array [100]\n```\n\n## API\n\nRejonson implements all the methods as described at [ReJson Commands](https://oss.redislabs.com/rejson/commands/) except for `JSON.DEBUG` and `JSON.RESP`.\n\nThe args will be serialized to redis directly so make sure to read [ReJSON command docs](https://oss.redislabs.com/redisjson/commands/)\n\n\nAll the rejson methods starts with the prefix of `Json` e.g `JsonDel`, `JsonArrIndex`, `JsonMGet`.\u003cbr/\u003eEach command returns specific `go-redis.Cmder` by the specific request.\n\n---------\nDue to some ReJSON bug - [#issue-76](https://github.com/RedisLabsModules/rejson/issues/76), some empty strings will be ignored.\n\n## Dependencies\nRejonson depends only on [go-redis](https://github.com/go-redis/redis). The [testing](#testing) also depends on assert library\n## Test\n\n\u003cb\u003eRejonson tests must use real redis with ReJson module to run\u003c/b\u003e\n\nIt is recommended to run the tests when using rejonson.\u003c/br\u003eThe unit tests will make sure your `go-redis` version is compatible and your `rejson` plugin supports all the methods and working as expected.\n\nThe testing library depends on [assert](https://github.com/stretchr/testify/assert) library\n\n## License\nApache 2.0\n\n## Contact\nFor any question or contribution, feel free to open an issue.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkromdaniel%2Frejonson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkromdaniel%2Frejonson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkromdaniel%2Frejonson/lists"}