{"id":18548983,"url":"https://github.com/danthe1st/compile-time-json-parser","last_synced_at":"2025-05-15T08:14:47.338Z","repository":{"id":57732910,"uuid":"354936998","full_name":"danthe1st/compile-time-json-parser","owner":"danthe1st","description":"generates a JSON-parser for Java-objects at compile-time","archived":false,"fork":false,"pushed_at":"2023-11-15T08:48:38.000Z","size":114,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T09:45:08.661Z","etag":null,"topics":["annotation-processor","java","json-java","json-parser","json-parsing-library"],"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/danthe1st.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-05T18:44:26.000Z","updated_at":"2023-05-07T20:09:45.000Z","dependencies_parsed_at":"2023-11-15T09:47:38.839Z","dependency_job_id":null,"html_url":"https://github.com/danthe1st/compile-time-json-parser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danthe1st%2Fcompile-time-json-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danthe1st%2Fcompile-time-json-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danthe1st%2Fcompile-time-json-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danthe1st%2Fcompile-time-json-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danthe1st","download_url":"https://codeload.github.com/danthe1st/compile-time-json-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301620,"owners_count":22047907,"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":["annotation-processor","java","json-java","json-parser","json-parsing-library"],"created_at":"2024-11-06T20:36:22.687Z","updated_at":"2025-05-15T08:14:47.315Z","avatar_url":"https://github.com/danthe1st.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compile-time JSON-parser [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser)\n\u003e generates a JSON-parser for Java-objects at compile-time\n\nCompile-time JSON-parser supports both non-private variables and properties.\n\nThe generated JSON-parser uses `org.json:json`.\n\n### Setup\n* [Download](https://maven.apache.org/download.cgi) and [install](https://maven.apache.org/install.html) [Maven](https://maven.apache.org/)\n* Download the sources\n* Run `mvn clean install` in the directory of Compile-time JSON-parser\n* Create a Maven Project in IntelliJ where you want to use Compile-time JSON-parser\n* Add the following dependency to the `pom.xml` of the project where you want to use Compile-time JSON-parser (replace `VERSION` with the version from [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser))\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.danthe1st\u003c/groupId\u003e\n    \u003cartifactId\u003ecompile-time-json-parser\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n* If you wish to use JPMS, also add the annotation processor to the `maven-compiler-plugin`\n```xml\n\u003cplugin\u003e\n\t\u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n\t\u003cversion\u003e3.8.1\u003c/version\u003e\n\t\u003cconfiguration\u003e\n\t\t\u003crelease\u003e11\u003c/release\u003e\n\t\t\u003cannotationProcessorPaths\u003e\n\t\t\t\u003cannotationProcessorPath\u003e\n\t\t\t\t\u003cgroupId\u003eio.github.danthe1st\u003c/groupId\u003e\n\t\t\t\t\u003cartifactId\u003ecompile-time-json-parser\u003c/artifactId\u003e\n\t\t\t\t\u003cversion\u003eVERSION\u003c/version\u003e\n\t\t\t\u003c/annotationProcessorPath\u003e\n\t\t\u003c/annotationProcessorPaths\u003e\n\t\u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n* Enable annotation processing for this project under `Settings`\u003e`Build, Execution, Deployment`\u003e`Compiler`\u003e`Annotation Processors`\u003e`Enable Annotation Processing`\n\n### Usage\n* Create a data class and annotate it with `@GenerateJSON` like this:\n\n```java\nimport io.github.danthe1st.json_compile.api.GenerateJSON;\n@GenerateJSON\npublic class TestClass {\n  public int someInt;\n  private String someString;\n  private int[][] someArray;\n\n  public String getSomeString() {\n    return someString;\n  }\n\n  public void setSomeString(String someString) {\n    this.someString = someString;\n  }\n\n  public int[][] getSomeArray() {\n    return someArray;\n  }\n\n  public void setSomeArray(int[][] someArray) {\n    this.someArray = someArray;\n  }\n  \n  @Override\n  public String toString() {\n    return \"TestClass{\" +\n            \"someInt=\" + someInt +\n            \", someString='\" + someString + '\\'' +\n            \", someArray=\" + Arrays.deepToString(someArray) +\n            '}';\n  }\n}\n```\n* When compiling the class, a class suffixed with `JSONLoader` should be automatically generated.\u003cbr/\u003e\n  This class contains a method named `fromJSON` that creates an instance of the data class from a `String`:\n  \n```java\nString json= String.join(\"\", Files.readAllLines(Path.of(\"testClass.json\")));\nTestClass obj = TestClassJSONLoader.fromJSON(json);\nSystem.out.println(obj);\nTestClass testObj=new TestClass();\ntestObj.setSomeString(\"test\");\ntestObj.someInt=12345;\ntestObj.someArray=new int[][]{{1,2,3},{},null,{1,2,3,4,5,6}};\nSystem.out.println(TestClassJSONLoader.toJSON(testObj));\n```\n\n### Example\n\nAn example project can be found in the directory `examples/maven-example`.\n\n* Import `Compile-time JSON-parser` in IntelliJ as a maven project\n* Run `mvn clean install` in that project\n* Expand the `examples/maven-example` directory\n* Right-click on the file `pom.xml` in that directory and select `Add as a Maven Project`\n* [Make sure you set up your IDE correctly](#ide-specific-configuration)\n* Run `TestClass` in `examples/maven-example/src/main/java/io/github/danthe1st/json_compile/test/TestClass`\n\n### Supported types\n* `String`\n* `int`\n* `long`\n* `float`\n* `double`\n* `boolean`\n* Enums\n* Wrapper classes for supported primitive types\n* Objects of classes annotated with `@GenerateJSON`\n* `Collection`s if they are not part of other collections or arrays, `Collections` of classes annotated with `@GenerateJSON` that contain collections are supported, however\n* Arrays\n* `org.json.JSONObject` and `org.json.JSONArray`\n\n### Limitations\n* It is not possible to create an array/collection of collections\n* Objects annotated with `@GenerateJSON` need to have a no-args-constructor\n* Collections need to be initialized in the constructor\n* Generic objects are not supported (except generic collections)\n* Configuration is not supported\n\n### IDE-specific configuration\n\n### Eclipse\n* Install the [m2e-apt plugin](https://marketplace.eclipse.org/content/m2e-apt)\n  [![Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client](https://marketplace.eclipse.org/sites/all/themes/solstice/public/images/marketplace/btn-install.svg)](http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=1216155 \"Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client\")\n\n![m2e-apt](https://user-images.githubusercontent.com/34687786/114560029-9713f280-9c6c-11eb-889d-096ee46b52c0.png)\n\n* Right-click the project, open `Properties`\u003e`Java Compiler`\u003e`Annotation Processing`\u003e and select `Enable Project Specific Settings` and `Enable processing in Editor`\n\n### IntelliJ\n* Enable annotation processing for this project under `Settings`\u003e`Build, Execution, Deployment`\u003e`Compiler`\u003e`Annotation Processors`\u003e`Maven default annotation processors profile`\u003e`json-parser-maven-example`\u003e`Enable Annotation Processing`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanthe1st%2Fcompile-time-json-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanthe1st%2Fcompile-time-json-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanthe1st%2Fcompile-time-json-parser/lists"}