{"id":16541926,"url":"https://github.com/itzg/jsonschema2pojo-rules-bettermaps","last_synced_at":"2026-02-19T02:01:38.180Z","repository":{"id":145317914,"uuid":"85710520","full_name":"itzg/jsonschema2pojo-rules-bettermaps","owner":"itzg","description":"Custom RuleFactory for the jsonschema2pojo facility that identifies additionalProperties that only declare a simple type and generates a Map without an intermediate property POJO.","archived":false,"fork":false,"pushed_at":"2017-03-21T15:46:57.000Z","size":26,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-20T13:44:24.386Z","etag":null,"topics":["java","json-schema","maven-plugin"],"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/itzg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2017-03-21T14:17:10.000Z","updated_at":"2024-07-18T00:04:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"68ba1bc5-86e8-4978-89fa-ea400b7653be","html_url":"https://github.com/itzg/jsonschema2pojo-rules-bettermaps","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/itzg/jsonschema2pojo-rules-bettermaps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzg%2Fjsonschema2pojo-rules-bettermaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzg%2Fjsonschema2pojo-rules-bettermaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzg%2Fjsonschema2pojo-rules-bettermaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzg%2Fjsonschema2pojo-rules-bettermaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzg","download_url":"https://codeload.github.com/itzg/jsonschema2pojo-rules-bettermaps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzg%2Fjsonschema2pojo-rules-bettermaps/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29600844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T00:59:38.239Z","status":"online","status_checked_at":"2026-02-19T02:00:07.702Z","response_time":117,"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":["java","json-schema","maven-plugin"],"created_at":"2024-10-11T18:56:14.718Z","updated_at":"2026-02-19T02:01:38.163Z","avatar_url":"https://github.com/itzg.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a custom `RuleFactory` for the [jsonschema2pojo facility](https://github.com/joelittlejohn/jsonschema2pojo)\nthat identifies `additionalProperties` that only declare a simple type and generates a \n`Map\u003cString,TYPE\u003e` where `TYPE` is the boxed type of the property, such as `String`, or `Integer`.\n\nTo use it with the Maven plugin, add this artifact as a dependency of the plugin and set\nthe `customRuleFactory` to `me.itzg.jsonschema2pojo.bettermaps.BetterMapsRuleFactory`.\n\nFor example,\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.jsonschema2pojo\u003c/groupId\u003e\n    \u003cartifactId\u003ejsonschema2pojo-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e${jsonschema2pojo.version}\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003csourceDirectory\u003e${basedir}/src/main/resources/schema\u003c/sourceDirectory\u003e\n        \u003c!-- ...other config --\u003e\n        \u003ccustomRuleFactory\u003eme.itzg.jsonschema2pojo.bettermaps.BetterMapsRuleFactory\u003c/customRuleFactory\u003e\n    \u003c/configuration\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003egenerate\u003c/goal\u003e\n            \u003c/goals\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eme.itzg\u003c/groupId\u003e\n            \u003cartifactId\u003ejsonschema2pojo-rules-bettermaps\u003c/artifactId\u003e\n            \u003cversion\u003e1.0-SNAPSHOT\u003c/version\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/plugin\u003e\n\n```\n\n## Example\n\nGiven the following schema,\n\n```json\n{\n  \"type\":\"object\",\n  \"properties\": {\n    \"foo\": {\n      \"type\": \"string\"\n    },\n    \"bars\": {\n      \"type\": \"object\",\n      \"additionalProperties\": {\n        \"type\":\"string\"\n      }\n    },\n    \"times\": {\n      \"type\": \"object\",\n      \"additionalProperties\": {\n        \"type\":\"integer\"\n      }\n    },\n    \"baz\": {\n       \"type\": \"object\",\n       \"additionalProperties\": {\n         \"type\": \"object\",\n         \"properties\": {\n           \"key\": {\n             \"type\": \"string\"\n           },\n           \"value\": {\n             \"type\": \"string\"\n           }\n         }\n       }\n    }\n  }\n}\n```\n\nThe root class, called `MyClass` in this example, contains direct `Map` fields for `bars` and `times`\nwithout the need to reference or declare additional POJO types. The field `baz` still generates\na POJO that contains fields `key` and `value` since it itself is a complex structure.\n\n\n```java\npublic class MyClass {\n\n    @JsonProperty(\"foo\")\n    private String foo;\n    @JsonProperty(\"bars\")\n    private Map\u003cString, String\u003e bars;\n    @JsonProperty(\"times\")\n    private Map\u003cString, Integer\u003e times;\n    @JsonProperty(\"baz\")\n    private Baz baz;\n    // ...snip\n}\n\npublic class Baz {\n\n    @JsonIgnore\n    private Map\u003cString, BazProperty\u003e additionalProperties = \n        new HashMap\u003cString, BazProperty\u003e();\n    // ...snip\n}\n\npublic class BazProperty {\n\n    @JsonProperty(\"key\")\n    private String key;\n    @JsonProperty(\"value\")\n    private String value;\n    // ...snip\n}\n```\n\nThe `Baz` and `BazProperty` effectively demonstrate the benefit of this rule factory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzg%2Fjsonschema2pojo-rules-bettermaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzg%2Fjsonschema2pojo-rules-bettermaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzg%2Fjsonschema2pojo-rules-bettermaps/lists"}