{"id":15798510,"url":"https://github.com/chanced/cmpjson","last_synced_at":"2025-07-22T05:03:41.608Z","repository":{"id":57575895,"uuid":"356352068","full_name":"chanced/cmpjson","owner":"chanced","description":"A simple package for Go that compares JSON","archived":false,"fork":false,"pushed_at":"2022-01-14T19:43:06.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-06T00:41:45.469Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/chanced.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}},"created_at":"2021-04-09T17:36:17.000Z","updated_at":"2022-01-14T19:35:37.000Z","dependencies_parsed_at":"2022-08-29T00:50:37.845Z","dependency_job_id":null,"html_url":"https://github.com/chanced/cmpjson","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/chanced/cmpjson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fcmpjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fcmpjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fcmpjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fcmpjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanced","download_url":"https://codeload.github.com/chanced/cmpjson/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanced%2Fcmpjson/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266430671,"owners_count":23927165,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-05T00:42:11.086Z","updated_at":"2025-07-22T05:03:41.586Z","avatar_url":"https://github.com/chanced.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmpjson\n\nA simple package for Go that compares JSON for testing purposes.\n\nTo determine whether json is\nequal,[github.com/evanphx/json-patch/v5](https://github.com/evanphx/json-patch)\nis utilized. If the json is not equal, a diff is created utilizing\n[github.com/wI2L/jsondiff](https://github.com/wI2L/jsondiff).\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"testing\"\n\n\t\"github.com/chanced/cmpjson\"\n)\n\nfunc TestSomething(t *testing.T) {\n\tdataA := []byte(`{\n\t\t\"fieldA\": [\"1\", \"2\", \"3\"],\n\t\t\"fieldB\": \"str\"\n\t}`)\n\tdataB := []byte(`{\n\t\t\"fieldB\": \"str\",\n\t\t\"fieldA\": [\"2\",\"3\"]\n\t}`)\n\tif ok, diff, err := cmpjson.Equal(dataA, dataB); !ok {\n\t\tt.Error(diff, err)\n\t}\n\t// alternatively:\n\tif ok, diff := cmpjson.MustEqual(dataA, dataB); !ok {\n\t\tt.Error(\"dataA and dataB were not equal:\", diff)\n\t}\n}\n\n\n```\n\nPrints:\n\n```\n\n=== RUN   TestSomething\n    /cmpjson/examples_test.go:84: [\n          {\n            \"op\": \"remove\",\n            \"path\": \"/fieldA/2\"\n          },\n          {\n            \"op\": \"replace\",\n            \"path\": \"/fieldA/0\",\n            \"value\": \"2\"\n          },\n          {\n            \"op\": \"replace\",\n            \"path\": \"/fieldA/1\",\n            \"value\": \"3\"\n          }\n        ] \u003cnil\u003e\n    /cmpjson/examples_test.go:88: dataA and dataB were not equal: [\n          {\n            \"op\": \"remove\",\n            \"path\": \"/fieldA/2\"\n          },\n          {\n            \"op\": \"replace\",\n            \"path\": \"/fieldA/0\",\n            \"value\": \"2\"\n          },\n          {\n            \"op\": \"replace\",\n            \"path\": \"/fieldA/1\",\n            \"value\": \"3\"\n          }\n        ]\n--- FAIL: TestSomething (0.00s)\nFAIL\nFAIL\tgithub.com/chanced/cmpjson\t0.245s\n```\n\n[https://play.golang.org/p/VMrggnGiydw](https://play.golang.org/p/VMrggnGiydw)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanced%2Fcmpjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanced%2Fcmpjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanced%2Fcmpjson/lists"}