{"id":13783841,"url":"https://github.com/everit-org/json-schema","last_synced_at":"2026-01-14T03:42:38.916Z","repository":{"id":37733042,"uuid":"42369667","full_name":"everit-org/json-schema","owner":"everit-org","description":"JSON Schema validator for java, based on the org.json API","archived":false,"fork":false,"pushed_at":"2025-02-09T17:13:52.000Z","size":2603,"stargazers_count":885,"open_issues_count":82,"forks_count":282,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-05-11T19:40:23.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/everit-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2015-09-12T19:14:35.000Z","updated_at":"2025-05-07T12:14:34.000Z","dependencies_parsed_at":"2022-07-13T03:50:32.685Z","dependency_job_id":"8a6db158-a9b4-4c7f-86a5-e2421823afd7","html_url":"https://github.com/everit-org/json-schema","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/everit-org/json-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everit-org%2Fjson-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everit-org%2Fjson-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everit-org%2Fjson-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everit-org%2Fjson-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/everit-org","download_url":"https://codeload.github.com/everit-org/json-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everit-org%2Fjson-schema/sbom","scorecard":{"id":386438,"data":{"date":"2025-08-11","repo":{"name":"github.com/everit-org/json-schema","commit":"e00a94ef6ee4fbda9b31afbed4d675875dcb6ae6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Code-Review","score":2,"reason":"Found 7/29 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T16:45:35.581Z","repository_id":37733042,"created_at":"2025-08-18T16:45:35.581Z","updated_at":"2025-08-18T16:45:35.581Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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-08-03T19:00:31.719Z","updated_at":"2026-01-14T03:42:38.905Z","avatar_url":"https://github.com/everit-org.png","language":"Java","readme":"# JSON Schema Validator \u003ca href=\"https://www.paypal.me/erosb88\"\u003e\u003cimg style=\"float: right\" width=\"70\" height=\"35\" src=\"./donate.jpg\" title=\"Support this project by making a donation\"\u003e\u003c/a\u003e\n\n## Deprecation notice\n\nThis library is currently in maintenance mode and superseded by [erosb/json-sKema](https://github.com/erosb/json-sKema).\n\nThis repository and won't see any new features. It provides solid support for draft-04, draft-06 and draft-07 versions of the JSON Schema specification.\n\nThe latest draft 2020-12 is supported only by [erosb/json-sKema](https://github.com/erosb/json-sKema).\n\n\n[![Apache 2.0 License][ASL 2.0 badge]][ASL 2.0] [![Build Status][Travis badge master]][Travis] [![Coverage Status][Coveralls.io badge master]][Coveralls.io] \n\n* [When to use this library?](#when-to-use-this-library)\n* [Maven installation](#maven-installation)\n  * [Java7 version](#java67-versions)\n* [Quickstart](#quickstart)\n* [Draft 4, Draft 6 or Draft 7?](#draft-4-draft-6-or-draft-7)\n* [Investigating failures](#investigating-failures)\n  * [JSON report of the failures](#json-report-of-the-failures)\n* [ValidationListeners - Tracking the validation process](#validationlisteners---tracking-the-validation-process)\n* [Early failure mode](#early-failure-mode)\n* [Lenient mode](#lenient-mode)\n* [Default values](#default-values)\n* [RegExp implementations](#regexp-implementations)\n* [readOnly and writeOnly context](#readonly-and-writeonly-context)\n* [Format validators](#format-validators)\n  * [Example](#example)\n* [$ref resolution](#ref-resolution)\n* [Excluding dependencies](#excluding-dependencies)\n* [Javadoc](#javadoc)\n\nThis project is an implementation of the JSON Schema [Draft v4][draft-zyp-json-schema-04], [Draft v6](https://tools.ietf.org/html/draft-wright-json-schema-01) and [Draft v7](https://tools.ietf.org/html/draft-handrews-json-schema-validation-00) specifications.\nIt uses the [org.json API](http://stleary.github.io/JSON-java/) (created by Douglas Crockford) for representing JSON data.\n\n# When to use this library?\n\nLets assume that you already know what JSON Schema is, and you want to utilize it in a Java application to validate JSON data.\nBut - as you may have already discovered - there is also an [other Java implementation][java-json-tools/json-schema-validator]\nof the JSON Schema specification. So here are some advices about which one to use:\n * if you use Jackson to handle JSON in Java code, then [java-json-tools/json-schema-validator] is obviously a better choice, since it uses Jackson\n * if you want to use the [org.json API](http://stleary.github.io/JSON-java/) then this library is the better choice\n * if you need JSON Schema Draft 6 / 7 support, then you need this library.\n * if you want to use anything else for handling JSON (like GSON or javax.json), then you are in a little trouble, since\ncurrently there is no schema validation library backed by these libraries. It means that you will have to parse the JSON\ntwice: once for the schema validator, and once for your own processing. In a case like that, this library is probably still\na better choice, since it seems to be [twice faster](https://github.com/erosb/json-schema-perftest) than the Jackson-based [java-json-tools][java-json-tools/json-schema-validator] library.\n\n\n## Maven installation\n\nAdd the following dependency to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.erosb\u003c/groupId\u003e\n\t\u003cartifactId\u003eeverit-json-schema\u003c/artifactId\u003e\n\t\u003cversion\u003e1.14.6\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n_Note about older versions_: versions between `1.6.0` and `1.9.1` can only be found on [JitPack](https://jitpack.io/docs/) with `com.github.everit-org.json-schema:org.everit.json.schema` coordinates.  Versions `1.0.0` ... `1.5.1` are available on Maven Central under `org.everit.json:org.everit.json.schema` coordinates.\n\n### Java6/7 versions\n\nThere were a couple of attempts to make the library work on Java 6/7.\n\nA java6 port of version 1.9.2 was developed by @mindbender1 and it is accessible through Maven Central with the following coordinates:\n\n```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.erosb\u003c/groupId\u003e\n        \u003cartifactId\u003eeverit-json-schema-jdk6\u003c/artifactId\u003e\n        \u003cversion\u003e1.9.2\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n\nBackports of older versions:\n * version 1.4.1 was backported by [Doctusoft](https://doctusoft.com/) with coordinates `com.doctusoft:json-schema-java7:1.4.1`\n * version 1.1.1 was backported by @rdruilhe and is available on JitPack as `com.github.rdruilhe.json-schema:org.everit.json.schema:1.1.1`\n\n## Quickstart\n\n\n```java\nimport org.everit.json.schema.Schema;\nimport org.everit.json.schema.loader.SchemaLoader;\nimport org.json.JSONObject;\nimport org.json.JSONTokener;\n// ...\ntry (InputStream inputStream = getClass().getResourceAsStream(\"/path/to/your/schema.json\")) {\n  JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));\n  Schema schema = SchemaLoader.load(rawSchema);\n  schema.validate(new JSONObject(\"{\\\"hello\\\" : \\\"world\\\"}\")); // throws a ValidationException if this object is invalid\n}\n```\n\n## Draft 4, Draft 6 or Draft 7?\n\nJSON Schema has currently 4 major releases, Draft 3, Draft 4, Draft 6 and Draft 7. This library implements the 3 newer ones, you can have a quick look at the differences [here](https://github.com/json-schema-org/json-schema-spec/wiki/FAQ:-draft-wright-json-schema%5B-validation%5D-01#changes) and [here](https://tools.ietf.org/html/draft-handrews-json-schema-validation-00#appendix-B).\nSince the two versions have a number of differences - and draft 6 is not backwards-compatible with draft 4 - it is good to know which version will you use.   \n\nThe best way to denote the JSON Schema version you want to use is to include its meta-schema URL in the document root with the `\"$schema\"` key. This is a common notation, facilitated by the library to determine which version should be used.\n\nQuick reference:\n  * if there is `\"$schema\": \"http://json-schema.org/draft-04/schema\"` in the schema root, then Draft 4 will be used\n  * if there is `\"$schema\": \"http://json-schema.org/draft-06/schema\"` in the schema root, then Draft 6 will be used\n  * if there is `\"$schema\": \"http://json-schema.org/draft-07/schema\"` in the schema root, then Draft 7 will be used\n  * if none of these is found then Draft 4 will be assumed as default\n\nIf you want to specify the meta-schema version explicitly then you can change the default from Draft 4 to Draft 6 / 7 by configuring the loader this way:\n\n```java\nSchemaLoader loader = SchemaLoader.builder()\n                .schemaJson(yourSchemaJSON)\n                .draftV6Support() // or draftV7Support()\n                .build();\nSchema schema = loader.load().build();\n```\n\n## Investigating failures\n\n\nStarting from version `1.1.0` the validator collects every schema violations (instead of failing immediately on the first\none). Each failure is denoted by a JSON pointer, pointing from the root of the document to the violating part. If  more\nthan one schema violations have been detected, then a `ValidationException` will be thrown at the most common parent\nelements of the violations, and each separate violations can be obtained using the `ValidationException#getCausingExceptions()`\nmethod.\n\nTo demonstrate the above concepts, lets see an example. Lets consider the following schema:\n\n```json\n{\n\t\"type\" : \"object\",\n\t\"properties\" : {\n\t\t\"rectangle\" : {\"$ref\" : \"#/definitions/Rectangle\" }\n\t},\n\t\"definitions\" : {\n\t\t\"size\" : {\n\t\t\t\"type\" : \"number\",\n\t\t\t\"minimum\" : 0\n\t\t},\n\t\t\"Rectangle\" : {\n\t\t\t\"type\" : \"object\",\n\t\t\t\"properties\" : {\n\t\t\t\t\"a\" : {\"$ref\" : \"#/definitions/size\"},\n\t\t\t\t\"b\" : {\"$ref\" : \"#/definitions/size\"}\n\t\t\t}\n\t\t}\n\t}\n}\n```\n\nThe following JSON document has only one violation against the schema (since \"a\" cannot be negative):\n\n```json\n{\n\t\"rectangle\" : {\n\t\t\"a\" : -5,\n\t\t\"b\" : 5\n\t}\n}\n```\n\nIn this case the thrown `ValidationException` will point to `#/rectangle/a` and it won't contain sub-exceptions:\n\n```java\ntry {\n  schema.validate(rectangleSingleFailure);\n} catch (ValidationException e) {\n  // prints #/rectangle/a: -5.0 is not higher or equal to 0\n  System.out.println(e.getMessage());\n}\n```\n\n\nNow - to illustrate the way that multiple violations are handled - let's consider the following JSON document, where both\nthe \"a\" and \"b\" properties violate the above schema:\n\n```json\n{\n\t\"rectangle\" : {\n\t\t\"a\" : -5,\n\t\t\"b\" : \"asd\"\n\t}\n}\n```\n\nIn this case the thrown `ValidationException` will point to `#/rectangle`, and it has 2 sub-exceptions, pointing to\n`#/rectangle/a` and `#/rectangle/b` :\n\n```java\ntry {\n  schema.validate(rectangleMultipleFailures);\n} catch (ValidationException e) {\n  System.out.println(e.getMessage());\n  e.getCausingExceptions().stream()\n      .map(ValidationException::getMessage)\n      .forEach(System.out::println);\n}\n```\n\nThis will print the following output:\n```\n#/rectangle: 2 schema violations found\n#/rectangle/a: -5.0 is not higher or equal to 0\n#/rectangle/b: expected type: Number, found: String\n```\n\n### JSON report of the failures\n\nSince version `1.4.0` it is possible to print the `ValidationException` instances as\nJSON-formatted failure reports. The `ValidationException#toJSON()` method returns a `JSONObject` instance with the\nfollowing keys:\n\n * `\"message\"`: the programmer-friendly exception message (description of the validation failure)\n * `\"keyword\"`: the JSON Schema keyword which was violated\n * `\"pointerToViolation\"`: a JSON Pointer denoting the path from the input document root to its fragment which caused\n the validation failure\n * `\"schemaLocation\"`: a JSON Pointer denoting the path from the schema JSON root to the violated keyword\n * `\"causingExceptions\"`: a (possibly empty) array of sub-exceptions. Each sub-exception is represented as a JSON object,\n with the same structure as described in this listing. See more above about causing exceptions.\n\nPlease take into account that the complete failure report is a *hierarchical tree structure*: sub-causes of a cause can\nbe obtained using `#getCausingExceptions()` .\n\n## ValidationListeners - Tracking the validation process\n\n`ValidationListener`s can serve the purpose of resolving ambiguity about _how_ does an instance JSON match (or does not match)\nagainst a schema. You can attach a `ValidationListener` implementation to the validator to receive event notifications about intermediate\nsuccess/failure results. \n\nExample:\n\n```java\nimport org.everit.json.schema.Validator;\n...\nValidator validator = Validator.builder()\n\t.withListener(new YourValidationListenerImplementation())\n\t.build();\nvalidator.performValidation(schema, input);\n```\n\nThe currently supported events:\n\n * a `\"$ref\"` reference being resolved\n * a subschema under an `\"allOf\"` / `\"anyOf\"` / `\"oneOf\"` schema matching\n * a subschema under an `\"allOf\"` / `\"anyOf\"` / `\"oneOf\"` schema failing to match\n * an `\"if\"` schema matching\n * an `\"if\"` schema failing to match\n * an `\"then\"` schema matching\n * an `\"then\"` schema failing to match\n * an `\"else\"` schema matching\n * an `\"else\"` schema failing to match\n \n\nSee the javadoc of the `org.everit.json.schema.event.ValidationListener` interface for more details. The particular event classes also have\nproper `#toJSON()` and `#toString()` implementations so you can print them in an easily parse-able format.\n\n## Early failure mode\n\nBy default the validation error reporting in collecting mode (see the \"Investigating failures\" chapter). That is convenient for having a\ndetailed error report, but under some circumstances it is more appropriate to stop the validation when a failure is found without\nchecking the rest of the JSON document. To toggle this fast-failing validation mode\n * you have to explicitly build a `Validator` instance for your schema instead of calling `Schema#validate(input)`\n * you have to call the `failEarly()` method of `ValidatorBuilder`\n\nExample:\n\n```java\nimport org.everit.json.schema.Validator;\n...\nValidator validator = Validator.builder()\n\t.failEarly()\n\t.build();\nvalidator.performValidation(schema, input);\n```\n\n_Note: the `Validator` class is immutable and thread-safe, so you don't have to create a new one for each validation, it is enough\nto configure it only once._\n\n## Lenient mode\n\nIn some cases, when validating numbers or booleans, it makes sense to accept string values that are parseable as such primitives, because\nany successive processing will also automatically parse these literals into proper numeric and logical values. Also, non-string primitive values are trivial to convert to strings, so why not to permit any json primitives as strings?\n\nFor example, let's take this schema:\n\n```json\n{\n    \"properties\": {\n        \"booleanProp\": {\n            \"type\": \"boolean\"\n        },\n        \"integerProp\": {\n            \"type\": \"integer\"\n        },\n        \"nullProp\": {\n            \"type\": \"null\"\n        },\n        \"numberProp\": {\n            \"type\": \"number\"\n        },\n        \"stringProp\": {\n          \"type\": \"string\"\n        }\n    }\n}\n```\n\nThe following JSON document fails to validate, although all of the strings could easily be converted into appropriate values:\n\n```json\n{\n  \"numberProp\": \"12.34\",\n  \"integerProp\": \"12\",\n  \"booleanProp\": \"true\",\n  \"nullProp\": \"null\",\n  \"stringProp\": 12.34\n}\n```\n\nIn this case, if you want the above instance to pass the validation against the schema, you need to use the lenient primitive validation configuration turned on. Example:\n\n\n```java\nimport org.everit.json.schema.*;\n...\nValidator validator = Validator.builder()\n\t.primitiveValidationStrategry(PrimitiveValidationStrategy.LENIENT)\n\t.build();\nvalidator.performValidation(schema, input);\n```\n\n_Note: in lenient parsing mode, [all 22 possible boolean literals](https://yaml.org/type/bool.html) will be accepted as logical values._\n\n\n\n## Default values\n\nThe JSON Schema specification defines the \"default\" keyword for denoting default values, though it doesn't explicitly state how it should\naffect the validation process. By default this library doesn't set the default values, but if you need this feature, you can turn it on\nby the `SchemaLoaderBuilder#useDefaults(boolean)` method, before loading the schema:\n\n```json\n{\n  \"properties\": {\n    \"prop\": {\n      \"type\": \"number\",\n      \"default\": 1\n    }\n  }\n}\n```\n\n\n```java\nJSONObject input = new JSONObject(\"{}\");\nSystem.out.println(input.get(\"prop\")); // prints null\nSchema schema = SchemaLoader.builder()\n\t.useDefaults(true)\n\t.schemaJson(rawSchema)\n\t.build()\n\t.load().build();\nschema.validate(input);\nSystem.out.println(input.get(\"prop\")); // prints 1\n```\n\nIf there are some properties missing from `input` which have `\"default\"` values in the schema, then they will be set by the validator\nduring validation.\n\n## RegExp Implementations\n\nFor supporting the `\"regex\"` keyword of JSON Schema the library offers two possible implementations:\n * the default is based on the `java.util.regex` package\n * the other one is based on the [RE2J](https://github.com/google/re2j) library\n\nWhile the RE2J library provides significantly better performance than `java.util.regex`, it is not completely compatible with\nthe syntax supported by `java.util` or ECMA 262. So RE2J is recommended if you are concerned about performance and its limitations are acceptable.\n\nThe RE2J implementation can be activated with the `SchemaLoaderBuilder#regexpFactory()` call:\n\n```java\nSchemaLoader loader = SchemaLoader.builder()\n    .regexpFactory(new RE2JRegexpFactory())\n    // ...\n    .build();\n```\nNotes:\n - if you don't need the RE2J implementation, it is recommended to exclude it in your `pom.xml` so it doesn't increase your artifact's size unnecessarily\n - version history: in versions 1.0.0 ... 1.7.0 the `java.util` implementation was used, in 1.8.0 the RE2J implementation was used, and in 1.9.0 we made it\nconfigurable, due to some reported regressions.\n\n\n## readOnly and writeOnly context\n\nThe library supports the `readOnly` and `writeOnly` keywords which first appeared in Draft 7. If you want to utilize this feature, then before validation you need to tell the validator if the\nvalidation happens in read or write context. Example:\n\nschema.json:\n\n```json\n{\n   \"properties\": {\n     \"id\": {\n       \"type\": \"number\",\n       \"readOnly\": true\n     }\n   }  \n}\n```\n\nValidation code snippet:\n```java\n\nValidator validator = Validator.builder()\n                .readWriteContext(ReadWriteContext.WRITE)\n                .build();\n\nvalidator.performValidation(schema, new JSONObject(\"{\\\"id\\\":42}\"));\n```\n\nIn this case we told the validator that the validation happens in `WRITE` context, and in the input JSON object the `\"id\"` property appears, which is marked as `\"readOnly\"` in the schema, therefore this call will throw a `ValidationException`.\n\n## Format validators\n\n\nStarting from version `1.2.0` the library supports the [`\"format\"` keyword][draft-fge-json-schema-validation-00 format]\n(which is an optional part of the specification).\n\nThe supported formats vary depending on the schema spec version you use (since the standard formats were introduced in different versions on the validation specification).\n\nHere is a compatibility table of the supported standard formats:\n\n|                      | Draft 4            | Draft 6            | Draft 7            |\n|----------------------|--------------------|--------------------|--------------------|\n| date-time            | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n| email                | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n| hostname             | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n| ipv4                 | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n| ipv6                 | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n| uri                  | :white_check_mark: | :white_check_mark: | :white_check_mark: |\n| uri-reference        |                    | :white_check_mark: | :white_check_mark: |\n| uri-template         |                    | :white_check_mark: | :white_check_mark: |\n| json-pointer         |                    | :white_check_mark: | :white_check_mark: |\n| date                 |                    |                    | :white_check_mark: |\n| time                 |                    |                    | :white_check_mark: |\n| regex                |                    |                    | :white_check_mark: |\n| relative-json-pointer|                    |                    | :white_check_mark: |\n\n\nThe library also supports adding custom format validators. To use a custom validator basically you have to\n\n * create your own validation in a class implementing the `org.everit.json.schema.FormatValidator` interface\n * bind your validator to a name in a `org.everit.json.schema.loader.SchemaLoader.SchemaLoaderBuilder` instance before loading the actual schema\n\n### Example\n\n\n\nLets assume the task is to create a custom validator which accepts strings with an even number of characters.\n\nThe custom `FormatValidator` will look something like this:\n\n```java\npublic class EvenCharNumValidator implements FormatValidator {\n\n  @Override\n  public Optional\u003cString\u003e validate(final String subject) {\n    if (subject.length() % 2 == 0) {\n      return Optional.empty();\n    } else {\n      return Optional.of(String.format(\"the length of string [%s] is odd\", subject));\n    }\n  }\n\n}\n```\n\nTo bind the `EvenCharNumValidator` to a `\"format\"` value (for example `\"evenlength\"`) you have to bind a validator instance\nto the keyword in the schema loader configuration:\n\n```java\nJSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));\nSchemaLoader schemaLoader = SchemaLoader.builder()\n\t.schemaJson(rawSchema) // rawSchema is the JSON representation of the schema utilizing the \"evenlength\" non-standard format\n\t.addFormatValidator(\"evenlength\", new EvenCharNumValidator()) // the EvenCharNumValidator gets bound to the \"evenlength\" keyword\n\t.build();\nSchema schema = schemaLoader.load().build(); // the schema is created using the above created configuration\nschema.validate(jsonDocument);  // the document validation happens here\n```\n\n\n## $ref resolution\n\nIn a JSON Schema document it is possible to use relative URIs to refer previously defined\ntypes. Such references are expressed using the `\"$ref\"` and `\"$id\"` keywords. While the specification describes resolution scope alteration and dereferencing in detail, it doesn't explain the expected behavior when the first occurring `\"$ref\"` or `\"$id\"` is a relative URI.\n\nIn the case of this implementation it is possible to explicitly define an absolute URI serving as the base URI (resolution scope) using the appropriate builder method:\n\n```java\nSchemaLoader schemaLoader = SchemaLoader.builder()\n        .schemaJson(jsonSchema)\n        .resolutionScope(\"http://example.org/\") // setting the default resolution scope\n        .build();\n```\n\n### Loading from the classpath\n\nAs your schemas grow you will want to split that up into multiple source files and wire them with `\"$ref\"` references.\nIf you want to store the schemas on the classpath (instead of eg. serving them through HTTP) then the recommended way is\nto use the `classpath:` protocol to make the schemas reference each other. To make the `classpath:` protocol work:\n * if you use the [Spring framework](https://spring.io) you don't have to do anything, spring installs the necessary\n protocol handler out of the box\n * otherwise you can utilize the library's built-in classpath-aware `SchemaClient`, example:\n\n```java\nSchemaLoader schemaLoader = SchemaLoader.builder()\n        .schemaClient(SchemaClient.classPathAwareClient())\n        .schemaJson(jsonSchema)\n        .resolutionScope(\"classpath://my/schemas/directory/\") // setting the default resolution scope\n        .build();\n```\n\nGiven this configuration, the following references will be properly resolved in `jsonSchema`:\n\n```json\n{\n    \"properties\": {\n        \"sameDir\": { \"$ref\": \"sameDirSchema.json\" },\n        \"absPath\": { \"$ref\": \"classpath://somewhere/else/otherschema.json\" },\n        \"httpPath\": { \"$ref\": \"http://example.org/http-works-as-usual\" },\n    }\n}\n```\n\nand `sameDirSchema.json` will be looked for in `/my/schemas/directory/sameDirSchema.json` on the classpath.\n\n### Registering schemas by URI\n\nSometimes it is useful to work with preloaded schemas, to which we assign an arbitary URI (maybe an uuid) instead of\nloading the schema through a URL. This can be done by assigning the schemas to a URI with the `#registerSchemaByURI()` \nmethod of the schema loader. Example:\n\n```java\nSchemaLoader schemaLoader = SchemaLoader.builder()\n        .registerSchemaByURI(new URI(\"urn:uuid:a773c7a2-1a13-4f6a-a70d-694befe0ce63\"), aJSONObject)\n        .registerSchemaByURI(new URI(\"http://example.org\"), otherJSONObject)\n        .schemaJson(jsonSchema)\n        .resolutionScope(\"classpath://my/schemas/directory/\")\n        .build();\n```\n\nNotes: \n * the passed schema object must be a `JSONObject` or a `Boolean` (the formal parameter type is `Object` only because\n these two don't have any other common superclass).\n * if you want, you can pass a URL with HTTP protocol, it is still a valid URI. Since in this case you pre-assigned a schema\n to a URI, there will be no network call made. This can be a caching strategy (though defining your own `SchemaClient`\n implementation works too, or you can even utilize the extensible [protocol handling](https://stackoverflow.com/questions/26363573/registering-and-using-a-custom-java-net-url-protocol) of the `java.net` package)\n\n## Excluding dependencies\n\nSome of the dependencies can be excluded from the library, and it still remains usable, with some limitations:\n * if you exclude the `com.damnhandy:handy-uri-templates` dependency, then your schema shouldn't use the `\"uri-template\"` format\n * if you exclude the `commons-validator:commons-validator` dependency, then your schema shouldn't use the following formats: `\"email\"`, `\"ipv4\"`, `\"ipv6\"`, `\"hostname\"`\n\n\n## Javadoc\n\nBy library version:\n\n * [1.12.2](http://erosb.github.io/everit-json-schema/javadoc/1.12.2/)\n * [1.12.1](http://erosb.github.io/everit-json-schema/javadoc/1.12.1/)\n * [1.12.0](http://erosb.github.io/everit-json-schema/javadoc/1.12.0/)\n * [1.11.1](http://erosb.github.io/everit-json-schema/javadoc/1.11.1/)\n * [1.11.0](http://erosb.github.io/everit-json-schema/javadoc/1.11.0/)\n * [1.10.0](http://erosb.github.io/everit-json-schema/javadoc/1.10.0/)\n * [1.9.2](http://erosb.github.io/everit-json-schema/javadoc/1.9.2/)\n\nThe generated javadoc of versions 1.0.0 - 1.5.1 is available at [javadoc.io](http://javadoc.io/doc/org.everit.json/org.everit.json.schema/1.5.1)\n\nFor the versions in between (1.6.0 - 1.9.1) it isn't published anywhere.\n\n\n\n[ASL 2.0 badge]: https://img.shields.io/:license-Apache%202.0-blue.svg\n[ASL 2.0]: https://www.apache.org/licenses/LICENSE-2.0\n[Travis badge master]: https://travis-ci.org/everit-org/json-schema.svg?branch=master\n[Travis]: https://travis-ci.org/everit-org/json-schema\n[Coveralls.io badge master]: https://coveralls.io/repos/github/everit-org/json-schema/badge.svg?branch=master\n[Coveralls.io]: https://coveralls.io/github/everit-org/json-schema?branch=master\n[java-json-tools/json-schema-validator]: https://github.com/java-json-tools/json-schema-validator\n[draft-zyp-json-schema-04]: https://tools.ietf.org/html/draft-zyp-json-schema-04\n[draft-fge-json-schema-validation-00 format]: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-7\n\n","funding_links":["https://www.paypal.me/erosb88"],"categories":["Who Uses the Test Suite","HarmonyOS","\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":["Java","Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverit-org%2Fjson-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feverit-org%2Fjson-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverit-org%2Fjson-schema/lists"}