{"id":13412325,"url":"https://github.com/nitishm/go-rejson","last_synced_at":"2025-04-04T08:09:13.890Z","repository":{"id":41247851,"uuid":"130621116","full_name":"nitishm/go-rejson","owner":"nitishm","description":"Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)","archived":false,"fork":false,"pushed_at":"2024-01-17T12:52:03.000Z","size":4225,"stargazers_count":342,"open_issues_count":17,"forks_count":46,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-31T20:50:44.042Z","etag":null,"topics":["go-redis","golang","golang-client","json","multiclient","redigo","redis","redis-client","rejson"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitishm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-04-23T00:51:05.000Z","updated_at":"2024-07-30T05:26:39.000Z","dependencies_parsed_at":"2024-01-17T15:08:37.617Z","dependency_job_id":null,"html_url":"https://github.com/nitishm/go-rejson","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitishm%2Fgo-rejson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitishm%2Fgo-rejson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitishm%2Fgo-rejson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitishm%2Fgo-rejson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitishm","download_url":"https://codeload.github.com/nitishm/go-rejson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142070,"owners_count":20890652,"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-redis","golang","golang-client","json","multiclient","redigo","redis","redis-client","rejson"],"created_at":"2024-07-30T20:01:23.445Z","updated_at":"2025-04-04T08:09:13.867Z","avatar_url":"https://github.com/nitishm.png","language":"Go","funding_links":[],"categories":["Misc","数据库驱动`连接和操作数据库工具`","Data Integration Frameworks","Database Drivers","数据库驱动","数据库驱动程序","Go","NoSQL Databases","Generators"],"sub_categories":["SQL 查询语句构建库","NoSQL Database Drivers","Advanced Console UIs","NoSQL数据库驱动程序"],"readme":"\u003e _Note: Currently, go-ReJSON only support redislabs/rejson with version \u003c=1.0.8. If you are using higher versions, some commands might not work as expected_\n\n# Go-ReJSON - a golang client for ReJSON (a JSON data type for Redis)\n\nGo-ReJSON is a [Go](https://golang.org/) client for [ReJSON](https://github.com/RedisLabsModules/rejson) Redis Module.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/nitishm/go-rejson.svg)](https://pkg.go.dev/github.com/nitishm/go-rejson/v4)\n![test](https://github.com/nitishm/go-rejson/workflows/test/badge.svg)\n![code-analysis](https://github.com/nitishm/go-rejson/workflows/code-analysis/badge.svg)\n[![codecov](https://coveralls.io/repos/github/nitishm/go-rejson/badge.svg?branch=master)](https://coveralls.io/github/nitishm/go-rejson?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/nitishm/go-rejson)](https://goreportcard.com/report/github.com/nitishm/go-rejson)\n[![GitHub release](https://img.shields.io/github/release/nitishm/go-rejson.svg)](https://github.com/nitishm/go-rejson/releases)\n\n\u003e ReJSON is a Redis module that implements ECMA-404 The JSON Data Interchange Standard as a native data type. It allows storing, updating and fetching JSON values from Redis keys (documents).\n\nPrimary features of ReJSON Module:\n\n    * Full support of the JSON standard\n    * JSONPath-like syntax for selecting element inside documents\n    * Documents are stored as binary data in a tree structure, allowing fast access to sub-elements\n    * Typed atomic operations for all JSON values types\n\nEach and every feature of ReJSON Module is fully incorporated in the project.\n\nEnjoy ReJSON with the type-safe Redis client, [`Go-Redis/Redis`](https://github.com/go-redis/redis) or use the\nprint-like Redis-api client [`GoModule/Redigo`](https://github.com/gomodule/redigo). Go-ReJSON supports both the\nclients. Use any of the above two client you want, Go-ReJSON helps you out with all its features and functionalities in\na more generic and standard way.\n\nSupport for `mediocregopher/radix` and other Redis clients is in our RoadMap. Any contributions to the support for other\nclients is hearty welcome.\n\n## Installation\n\n    go get github.com/nitishm/go-rejson/v4\n\n## Example usage\n\n```golang\npackage main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"flag\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/nitishm/go-rejson/v4\"\n\tgoredis \"github.com/go-redis/redis/v8\"\n\t\"github.com/gomodule/redigo/redis\"\n)\n\n// Name - student name\ntype Name struct {\n\tFirst  string `json:\"first,omitempty\"`\n\tMiddle string `json:\"middle,omitempty\"`\n\tLast   string `json:\"last,omitempty\"`\n}\n\n// Student - student object\ntype Student struct {\n\tName Name `json:\"name,omitempty\"`\n\tRank int  `json:\"rank,omitempty\"`\n}\n\nfunc Example_JSONSet(rh *rejson.Handler) {\n\n\tstudent := Student{\n\t\tName: Name{\n\t\t\t\"Mark\",\n\t\t\t\"S\",\n\t\t\t\"Pronto\",\n\t\t},\n\t\tRank: 1,\n\t}\n\tres, err := rh.JSONSet(\"student\", \".\", student)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to JSONSet\")\n\t\treturn\n\t}\n\n\tif res.(string) == \"OK\" {\n\t\tfmt.Printf(\"Success: %s\\n\", res)\n\t} else {\n\t\tfmt.Println(\"Failed to Set: \")\n\t}\n\n\tstudentJSON, err := redis.Bytes(rh.JSONGet(\"student\", \".\"))\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to JSONGet\")\n\t\treturn\n\t}\n\n\treadStudent := Student{}\n\terr = json.Unmarshal(studentJSON, \u0026readStudent)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to JSON Unmarshal\")\n\t\treturn\n\t}\n\n\tfmt.Printf(\"Student read from redis : %#v\\n\", readStudent)\n}\n\nfunc main() {\n\tvar addr = flag.String(\"Server\", \"localhost:6379\", \"Redis server address\")\n\n\trh := rejson.NewReJSONHandler()\n\tflag.Parse()\n\n\t// Redigo Client\n\tconn, err := redis.Dial(\"tcp\", *addr)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to connect to redis-server @ %s\", *addr)\n\t}\n\tdefer func() {\n\t\t_, err = conn.Do(\"FLUSHALL\")\n\t\terr = conn.Close()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to communicate to redis-server @ %v\", err)\n\t\t}\n\t}()\n\trh.SetRedigoClient(conn)\n\tfmt.Println(\"Executing Example_JSONSET for Redigo Client\")\n\tExample_JSONSet(rh)\n\n\t// GoRedis Client\n\tcli := goredis.NewClient(\u0026goredis.Options{Addr: *addr})\n\tdefer func() {\n\t\tif err := cli.FlushAll(context.Background()).Err(); err != nil {\n\t\t\tlog.Fatalf(\"goredis - failed to flush: %v\", err)\n\t\t}\n\t\tif err := cli.Close(); err != nil {\n\t\t\tlog.Fatalf(\"goredis - failed to communicate to redis-server: %v\", err)\n\t\t}\n\t}()\n\trh.SetGoRedisClient(cli)\n\tfmt.Println(\"\\nExecuting Example_JSONSET for GoRedis Client\")\n\tExample_JSONSet(rh)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitishm%2Fgo-rejson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitishm%2Fgo-rejson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitishm%2Fgo-rejson/lists"}