{"id":19298239,"url":"https://github.com/casbin/json-adapter","last_synced_at":"2025-04-22T09:32:20.670Z","repository":{"id":57485573,"uuid":"114826272","full_name":"casbin/json-adapter","owner":"casbin","description":"JSON adapter for Casbin ","archived":false,"fork":false,"pushed_at":"2023-02-17T13:10:19.000Z","size":21,"stargazers_count":18,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T16:58:13.975Z","etag":null,"topics":["abac","access-control","acl","adapter","auth","authoritization","casbin","json","rbac","storage-driver"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/casbin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casbin.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},"funding":{"github":"casbin"}},"created_at":"2017-12-20T00:55:12.000Z","updated_at":"2024-07-04T15:43:37.000Z","dependencies_parsed_at":"2023-09-26T09:08:55.401Z","dependency_job_id":null,"html_url":"https://github.com/casbin/json-adapter","commit_stats":{"total_commits":11,"total_committers":4,"mean_commits":2.75,"dds":0.4545454545454546,"last_synced_commit":"65905f21a62a0c89ed1701729bc3d47334b544a6"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fjson-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fjson-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fjson-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fjson-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/json-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223175331,"owners_count":17100408,"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":["abac","access-control","acl","adapter","auth","authoritization","casbin","json","rbac","storage-driver"],"created_at":"2024-11-09T23:07:22.219Z","updated_at":"2024-11-09T23:07:22.746Z","avatar_url":"https://github.com/casbin.png","language":"Go","funding_links":["https://github.com/sponsors/casbin"],"categories":[],"sub_categories":[],"readme":"JSON Adapter\n---\n\n[![Go](https://github.com/casbin/json-adapter/actions/workflows/default.yml/badge.svg)](https://github.com/casbin/json-adapter/actions/workflows/default.yml)\n[![Coverage Status](https://coveralls.io/repos/github/casbin/json-adapter/badge.svg?branch=master)](https://coveralls.io/github/casbin/json-adapter?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/json-adapter)](https://goreportcard.com/report/github.com/casbin/json-adapter)\n[![Godoc](https://godoc.org/github.com/casbin/json-adapter?status.svg)](https://godoc.org/github.com/casbin/json-adapter)\n\nJSON Adapter is the [JSON (JavaScript Object Notation)](https://www.json.org/) adapter for [Casbin](https://github.com/casbin/casbin). With this library, Casbin can load policy from JSON string or save policy to it.\n\n## Installation\n\n    go get github.com/casbin/json-adapter/v2\n\n## Simple Example\n\n```go\npackage main\n\nimport (\n\t\"github.com/casbin/casbin/v2\"\n\t\"github.com/casbin/json-adapter/v2\"\n)\n\nfunc main() {\n\t// Initialize a JSON adapter and use it in a Casbin enforcer:\n\tb := []byte{} // b stores Casbin policy in JSON bytes.\n\ta := jsonadapter.NewAdapter(\u0026b) // Use b as the data source. \n\te, _ := casbin.NewEnforcer(\"examples/rbac_model.conf\", a)\n\t\n\t// Load the policy from JSON bytes b.\n\te.LoadPolicy()\n\t\n\t// Check the permission.\n\te.Enforce(\"alice\", \"data1\", \"read\")\n\t\n\t// Modify the policy.\n\t// e.AddPolicy(...)\n\t// e.RemovePolicy(...)\n\t\n\t// Save the policy back to JSON bytes b.\n\te.SavePolicy()\n}\n```\n\n## Policy JSON\n\nThe following illustrates the expected JSON format for a policy.  The [rbac_policy.json](examples/rbac_policy.json) has the same policy found in [rbac_policy.csv](examples/rbac_policy.csv).\n\n```json\n[\n  {\"PType\":\"p\",\"V0\":\"alice\",\"V1\":\"data1\",\"V2\":\"read\"},\n  {\"PType\":\"p\",\"V0\":\"bob\",\"V1\":\"data2\",\"V2\":\"write\"},\n  {\"PType\":\"p\",\"V0\":\"data2_admin\",\"V1\":\"data2\",\"V2\":\"read\"},\n  {\"PType\":\"p\",\"V0\":\"data2_admin\",\"V1\":\"data2\",\"V2\":\"write\"},\n  {\"PType\":\"g\",\"V0\":\"alice\",\"V1\":\"data2_admin\"}\n]\n```\n\n## Getting Help\n\n- [Casbin](https://github.com/casbin/casbin)\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fjson-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fjson-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fjson-adapter/lists"}