{"id":27250656,"url":"https://github.com/corka149/jsonpatch","last_synced_at":"2025-04-11T00:59:16.513Z","repository":{"id":37854363,"uuid":"240954532","full_name":"corka149/jsonpatch","owner":"corka149","description":"A implementation of RFC 6902 in pure Elixir.","archived":false,"fork":false,"pushed_at":"2025-03-01T12:15:14.000Z","size":205,"stargazers_count":46,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T13:13:09.510Z","etag":null,"topics":["elixir","jsonpatch"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/corka149.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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,"publiccode":null,"codemeta":null}},"created_at":"2020-02-16T19:43:50.000Z","updated_at":"2025-03-01T12:15:17.000Z","dependencies_parsed_at":"2024-02-27T10:46:26.473Z","dependency_job_id":"6370e272-14a3-4021-abe1-3ffea6dd4b47","html_url":"https://github.com/corka149/jsonpatch","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corka149%2Fjsonpatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corka149%2Fjsonpatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corka149%2Fjsonpatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corka149%2Fjsonpatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corka149","download_url":"https://codeload.github.com/corka149/jsonpatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055444,"owners_count":21040191,"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":["elixir","jsonpatch"],"created_at":"2025-04-11T00:59:16.001Z","updated_at":"2025-04-11T00:59:16.499Z","avatar_url":"https://github.com/corka149.png","language":"Elixir","readme":"# Jsonpatch\n\n![Elixir CI](https://github.com/corka149/jsonpatch/workflows/Elixir%20CI/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/corka149/jsonpatch/badge.svg?branch=master)](https://coveralls.io/github/corka149/jsonpatch?branch=master)\n[![Generic badge](https://img.shields.io/badge/Mutation-Tested-success.svg)](https://shields.io/)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/corka149/jsonpatch/graphs/commit-activity)\n[![Hex.pm Version](https://img.shields.io/hexpm/v/jsonpatch.svg?style=flat-square)](https://hex.pm/packages/jsonpatch)\n\nAn implementation of [RFC 6902](https://tools.ietf.org/html/rfc6902) in pure Elixir.\n\nFeatures:\n\n- Creating a patch by comparing to maps and lists\n- Apply patches to maps and lists - supports operations:\n    - add\n    - replace\n    - remove\n    - copy\n    - move\n    - test\n- Escaping of \"`/`\" (by \"`~1`\") and \"`~`\" (by \"`~0`\")\n- Allow usage of `-` for appending things to list (Add and Copy operation)\n\n## Getting started\n\n### Installation\n\nThe package can be installed by adding `jsonpatch` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:jsonpatch, \"~\u003e 2.2\"}\n  ]\nend\n```\n\nThe docs can be found at [https://hexdocs.pm/jsonpatch](https://hexdocs.pm/jsonpatch).\n\n### Create a diff\n\n```elixir\niex\u003e source = %{\"name\" =\u003e \"Bob\", \"married\" =\u003e false, \"hobbies\" =\u003e [\"Sport\", \"Elixir\", \"Football\"]}\niex\u003e destination = %{\"name\" =\u003e \"Bob\", \"married\" =\u003e true, \"hobbies\" =\u003e [\"Elixir!\"], \"age\" =\u003e 33}\niex\u003e Jsonpatch.diff(source, destination)\n[\n  %{path: \"/married\", value: true, op: \"replace\"},\n  %{path: \"/hobbies/2\", op: \"remove\"},\n  %{path: \"/hobbies/1\", op: \"remove\"},\n  %{path: \"/hobbies/0\", value: \"Elixir!\", op: \"replace\"},\n  %{path: \"/age\", value: 33, op: \"add\"}\n]\n```\n\n### Apply patches\n\n```elixir\niex\u003e patch = [\n  %{op: \"add\", path: \"/age\", value: 33},\n  %{op: \"replace\", path: \"/hobbies/0\", value: \"Elixir!\"},\n  %{op: \"replace\", path: \"/married\", value: true},\n  %{op: \"remove\", path: \"/hobbies/1\"},\n  %{op: \"remove\", path: \"/hobbies/2\"}\n]\niex\u003e target = %{\"name\" =\u003e \"Bob\", \"married\" =\u003e false, \"hobbies\" =\u003e [\"Sport\", \"Elixir\", \"Football\"]}\niex\u003e Jsonpatch.apply_patch(patch, target)\n{:ok, %{\"name\" =\u003e \"Bob\", \"married\" =\u003e true, \"hobbies\" =\u003e [\"Elixir!\"], \"age\" =\u003e 33}}\n```\n\n## Important sources\n- [Official RFC 6902](https://tools.ietf.org/html/rfc6902)\n- [Inspiration: python-json-patch](https://github.com/stefankoegl/python-json-patch) \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorka149%2Fjsonpatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorka149%2Fjsonpatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorka149%2Fjsonpatch/lists"}