{"id":15297591,"url":"https://github.com/qaware/majx","last_synced_at":"2025-05-07T05:21:02.425Z","repository":{"id":57730844,"uuid":"97034900","full_name":"qaware/majx","owner":"qaware","description":"Matching JSON expressively","archived":false,"fork":false,"pushed_at":"2020-05-05T07:47:56.000Z","size":391,"stargazers_count":6,"open_issues_count":6,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T06:41:25.359Z","etag":null,"topics":["hacktoberfest","json","jvm","kotlin","mustache","pattern-matching","test"],"latest_commit_sha":null,"homepage":"","language":"Java","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/qaware.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":"2017-07-12T17:27:11.000Z","updated_at":"2024-01-13T23:56:58.000Z","dependencies_parsed_at":"2022-09-26T22:01:37.999Z","dependency_job_id":null,"html_url":"https://github.com/qaware/majx","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Fmajx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Fmajx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Fmajx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaware%2Fmajx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qaware","download_url":"https://codeload.github.com/qaware/majx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252818913,"owners_count":21808942,"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":["hacktoberfest","json","jvm","kotlin","mustache","pattern-matching","test"],"created_at":"2024-09-30T19:18:25.885Z","updated_at":"2025-05-07T05:21:02.408Z","avatar_url":"https://github.com/qaware.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![majx Logo](/doc/majx-logo-medium.png)\n## Matching JSON expressively\n[![Build Status](https://travis-ci.org/qaware/majx.svg?branch=master)](https://travis-ci.org/qaware/majx) [![Coverage Status](https://coveralls.io/repos/github/qaware/majx/badge.svg?branch=master)](https://coveralls.io/github/qaware/majx?branch=master) [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)]() [![Download](https://api.bintray.com/packages/qaware-oss/maven/majx/images/download.svg) ](https://bintray.com/qaware-oss/maven/majx/_latestVersion)\n\nMajx is a test library for the JVM written in Kotlin that verifies that a JSON document fulfils your expectations regarding\nstructure and values.\n\nYou provide two JSON documents\n\n1. The **actual** JSON that should be tested\n2. The **pattern** JSON that describes your expectations\n\nWe try to let you express almost all of your expectations in a flexible, readable\nand concise way within the **pattern**. To achieve this, the **pattern** may contain magic\nvalues, that are treated in a certain way.\n\n# Usage\n\nObtain a reference to the **actual** and **pattern** JSONs as `String`  \nor jackson's [`JsonNode`](https://fasterxml.github.io/jackson-databind/javadoc/2.8/com/fasterxml/jackson/databind/JsonNode.html)\nand pass them to\n\n- one of the static methods that the class `Majx` provides which throw `AssertionError`s\n- or use the hamcrest matcher `matchesJson` from class `IsMatchingJson`\n\n```\nimport static de.qaware.majx.Majx.assertJsonMatches;\nimport static de.qaware.majx.hamcrest.IsMatchingJson.matchesJson;\n\nString actual  = \"{ \\\"greeting\\\" : \\\"Hello, World!\\\", \\\"id\\\" : 12 }\";\nString pattern = \"{ \\\"greeting\\\" : \\\"Hello, World!\\\", \\\"id\\\" : \\\"...\\\" }\";\n\nassertJsonMatches(pattern, actual);\nassertThat(actual, matchesJson(pattern); // or use the hamcrest matcher\n```\n\nThis test would succeed for any value for the `\"id\"` property inside the **actual** JSON\nsince its expected value is the magic `\"...\"`-wildcard value in the **pattern** \n(See [Ignoring values](https://github.com/qaware/majx/wiki/Ignoring-values)).\n\nDetails on all available features can be found in the wiki:\n\n* [Matching properties and values exactly](https://github.com/qaware/majx/wiki/Matching-properties-and-values-exactly)\n* [Partial object matching](https://github.com/qaware/majx/wiki/Partial-object-matching)\n* [Partial array matching](https://github.com/qaware/majx/wiki/Partial-array-matching)\n* [Ignoring values](https://github.com/qaware/majx/wiki/Ignoring-values)\n* [Programmatic expectations](https://github.com/qaware/majx/wiki/Programmatic-expectations) through mustache expressions\n\n## Dependencies\n\nThe JARs are available via  [Maven Central](https://mvnrepository.com/artifact/de.qaware.majx/majx)  \nand [JCenter](https://bintray.com/qaware-oss/maven/majx).\n\nIf you are using Maven to build your project, add the following to the `pom.xml` file.\n\n```XML\n\u003c!-- https://mvnrepository.com/artifact/de.qaware.majx/majx --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.qaware.majx\u003c/groupId\u003e\n    \u003cartifactId\u003emajx\u003c/artifactId\u003e\n    \u003cversion\u003e1.3.1\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\nIn case you are using Gradle to build your project, add the following to the `build.gradle` file:\n\n```groovy\nrepositories {\n    jcenter()\n    mavenCentral()\n}\n\ndependencies {\n    // https://mvnrepository.com/artifact/de.qaware.majx/majx\n    testImplementation group: 'de.qaware.majx', name: 'majx', version: '1.3.1'\n}\n```\n\n# Related Work\n\n* Hamcrest matchers for JSON documents, https://github.com/hertzsprung/hamcrest-json\n* Write JSON unit tests in less code, https://github.com/skyscreamer/JSONassert\n* Compare JSON in your Unit Tests, https://github.com/lukas-krecan/JsonUnit\n\n# Development Notes\n\nSee [Development Notes in the Wiki](https://github.com/qaware/majx/wiki/Development-Notes).\n\n# Maintainer\n\nClaudius Boettcher, \u003cclaudius.boettcher@qaware.de\u003e.\n\n# License\n\nThis software is provided under the MIT open source license, read the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaware%2Fmajx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqaware%2Fmajx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaware%2Fmajx/lists"}