{"id":15042845,"url":"https://github.com/unitvectory-labs/jsonassertify","last_synced_at":"2026-05-18T06:36:13.806Z","repository":{"id":246119664,"uuid":"820151814","full_name":"UnitVectorY-Labs/JSONassertify","owner":"UnitVectorY-Labs","description":"Write JSON unit tests in less code. Great for testing REST interfaces.","archived":false,"fork":false,"pushed_at":"2025-04-26T11:34:39.000Z","size":424,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-08T00:14:10.507Z","etag":null,"topics":["java-8","json","junit"],"latest_commit_sha":null,"homepage":"https://jsonassertify.unitvectorylabs.com/","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"skyscreamer/JSONassert","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UnitVectorY-Labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2024-06-25T22:59:48.000Z","updated_at":"2025-04-26T11:34:41.000Z","dependencies_parsed_at":"2025-04-26T12:27:16.188Z","dependency_job_id":"68bca3e7-571a-479f-9e52-c04434de5427","html_url":"https://github.com/UnitVectorY-Labs/JSONassertify","commit_stats":null,"previous_names":["unitvectory-labs/jsonassertify"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2FJSONassertify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2FJSONassertify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2FJSONassertify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2FJSONassertify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UnitVectorY-Labs","download_url":"https://codeload.github.com/UnitVectorY-Labs/JSONassertify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973669,"owners_count":21834108,"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":["java-8","json","junit"],"created_at":"2024-09-24T20:48:07.367Z","updated_at":"2026-05-18T06:36:13.801Z","avatar_url":"https://github.com/UnitVectorY-Labs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub release](https://img.shields.io/github/release/UnitVectorY-Labs/JSONassertify.svg)](https://github.com/UnitVectorY-Labs/JSONassertify/releases/latest) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Active](https://img.shields.io/badge/Status-Active-green)](https://unitvectory-labs.github.io/uvy-labs-guide/bestpractices/status/#active) [![Maven Central](https://img.shields.io/maven-central/v/com.unitvectory/jsonassertify)](https://central.sonatype.com/artifact/com.unitvectory/jsonassertify) [![javadoc](https://javadoc.io/badge2/com.unitvectory/jsonassertify/javadoc.svg)](https://javadoc.io/doc/com.unitvectory/jsonassertify) [![codecov](https://codecov.io/gh/UnitVectorY-Labs/JSONassertify/graph/badge.svg?token=AkErQGHlR1)](https://codecov.io/gh/UnitVectorY-Labs/JSONassertify)\n\nJSONassertify\n=============\n\nWrite JSON unit tests in less code.  Great for testing REST interfaces.\n\nJSONassertify: A Fork of JSONassert\n-----------------------------------\n\nJSONassert has been a valuable tool for simplifying JSON comparisons in unit tests for over a decade. While we deeply appreciate the original developers' contributions, the project has seen limited updates in recent years. To address current needs and modernize the tool, we have created [JSONassertify](https://github.com/UnitVectorY-Labs/JSONassertify), a fork of [JSONassert](https://github.com/skyscreamer/JSONassert) version 1.5.1.\n\nThis fork aims to update and enhance the codebase, introducing some necessary breaking changes while continuing to support older Java versions. Notably, this follows the recent release of [JSONassert 1.5.2](https://github.com/skyscreamer/JSONassert/pull/188), which unexpectedly required Java 21, as discussed [here](https://github.com/skyscreamer/JSONassert/issues/190). Our goal with JSONassertify is not to maintain perfect compatibility with the original but to improve and modernize the project.\n\nKey changes include:\n\n- New project name and package moving from `org.skyscreamer.jsonassert` to `com.unitvectory.jsonassertify`\n- Updating dependencies to the latest versions to address security issues\n- Utilizing Dependabot to keep dependencies up-to-date on an ongoing basis\n- Upgrade from JUnit4 to JUnit 5 in the unit tests used by the project\n- Transitioning to the `org.json` library from the less common and not maintained `com.vaadin.external.google: android-json` (this has the possibility of introducing breaking changes)\n- Implementing GitHub Actions for automated builds\n- Move from targeting Java 6 to targeting Java 8 with the intent of maintaining this backwards compatibility until Java 8 is fully deprecated as a build target\n- Overall formatting improvements of the code base including addition of missing Java Docs.\n\nThings that will stay the same:\n\n- The overwhelming majority of the codebase remains unchanged, this is the same library with the same functionality as JSONassert and changes and fixes will be made with care to maintain compatibility\n- Same classes and same methods (just under a different package)\n- Same Apache 2.0 License as the original project\n\nMigration Guide and Usage\n-------------------------\n\nThe intent is for JSONassertify to be a drop in replacement for JSONassert. Migrating is intended to be straightforward but there are a few things to keep in mind.\n\n1. Update the dependency to use JSONassertify\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.unitvectory\u003c/groupId\u003e\n    \u003cartifactId\u003ejsonassertify\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.5\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n2. Update the package imports\n\nFor most projects this is as simple as replacing the original import...\n\n```java\nimport org.skyscreamer.jsonassert.JSONAssert;\n```\n\nwith the import to reference the new package...\n\n```java\nimport com.unitvectory.jsonassertify.JSONAssert;\n```\n\n3. Check for org.json compatibility issues.\n\nThe change of the underlying JSON library to use org.json is one of the modernization and security considerations that is a potential breaking change.  The way this library parses JSON is different from the over decade old [com.vaadin.external.google:android-json](https://mvnrepository.com/artifact/com.vaadin.external.google/android-json/0.0.20131108.vaadin1) library used by JSONassert.\n\nOne notable change is how duplicate JSON keys are handled, the original library would allow those to be parsed where the most recent version of org.json will throw an error as part of the parsing before JSONassertify is able to perform a comparison of the objects.\n\nSummary\n-------\n\nWrite JSON tests as if you are comparing a string.  Under the covers, JSONassertify converts your string into a JSON object and compares the logical structure and data with the actual JSON.  When _strict_ is set to false (recommended), it forgives reordering data and extending results (as long as all the expected elements are there), making tests less brittle.\n\nSupported test frameworks:\n\n- [JUnit](http://junit.org)\n\nExamples\n--------\n\nIn JSONassertify you write and maintain something like this:\n\n```java\nJSONObject data = getRESTData(\"/friends/367.json\");\nString expected = \"{friends:[{id:123,name:\\\"Corby Page\\\"},{id:456,name:\\\"Carter Page\\\"}]}\";\nJSONAssert.assertEquals(expected, data, false);\n```\n\ninstead of all this:\n\n\u003cpre\u003e\u003ccode\u003e\u003cdel\u003e\nJSONObject data = getRESTData(\"/friends/367.json\");\nAssert.assertTrue(data.has(\"friends\"));\nObject friendsObject = data.get(\"friends\");\nAssert.assertTrue(friendsObject instanceof JSONArray);\nJSONArray friends = (JSONArray) friendsObject;\nAssert.assertEquals(2, data.length());\nJSONObject friend1Obj = friends.getJSONObject(data.get(0));\nAssert.true(friend1Obj.has(\"id\"));\nAssert.true(friend1Obj.has(\"name\"));\nJSONObject friend2Obj = friends.getJSONObject(data.get(1));\nAssert.true(friend2Obj.has(\"id\"));\nAssert.true(friend2Obj.has(\"name\"));\nif (\"Carter Page\".equals(friend1Obj.getString(\"name\"))) {\n    Assert.assertEquals(123, friend1Obj.getInt(\"id\"));\n    Assert.assertEquals(\"Corby Page\", friend2Obj.getString(\"name\"));\n    Assert.assertEquals(456, friend2Obj.getInt(\"id\"));\n}\nelse if (\"Corby Page\".equals(friend1Obj.getString(\"name\"))) {\n    Assert.assertEquals(456, friend1Obj.getInt(\"id\"));\n    Assert.assertEquals(\"Carter Page\", friend2Obj.getString(\"name\"));\n    Assert.assertEquals(123, friend2Obj.getInt(\"id\"));\n}\nelse {\n    Assert.fail(\"Expected either Carter or Corby, Got: \" + friend1Obj.getString(\"name\"));\n}\n\u003c/del\u003e\u003c/code\u003e\u003c/pre\u003e\n\nError Messages\n--------------\n\nWe tried to make error messages easy to understand.  This is really important, since it gets hard for the eye to pick out the difference, particularly in long JSON strings.  For example:\n\n```java\nString expected = \"{id:1,name:\\\"Joe\\\",friends:[{id:2,name:\\\"Pat\\\",pets:[\\\"dog\\\"]},{id:3,name:\\\"Sue\\\",pets:[\\\"bird\\\",\\\"fish\\\"]}],pets:[]}\";\nString actual = \"{id:1,name:\\\"Joe\\\",friends:[{id:2,name:\\\"Pat\\\",pets:[\\\"dog\\\"]},{id:3,name:\\\"Sue\\\",pets:[\\\"cat\\\",\\\"fish\\\"]}],pets:[]}\"\nJSONAssert.assertEquals(expected, actual, false);\n```\n\nreturns the following:\n\n```\nfriends[id=3].pets[]: Expected bird, but not found ; friends[id=3].pets[]: Contains cat, but not expected\n```\n\nWhich tells you that the pets array under the friend where id=3 was supposed to contain \"bird\", but had \"cat\" instead.  (Maybe the cat ate the bird?)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funitvectory-labs%2Fjsonassertify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funitvectory-labs%2Fjsonassertify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funitvectory-labs%2Fjsonassertify/lists"}