Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.joelittlejohn:jsonschema2pojo:jsonschema2pojo-1.2.2'
}
dependencies {
implementation("com.github.joelittlejohn:jsonschema2pojo:jsonschema2pojo-1.2.2")
}
<dependency>
<groupId>com.github.joelittlejohn</groupId>
<artifactId>jsonschema2pojo</artifactId>
<version>jsonschema2pojo-1.2.2</version>
</dependency>
libraryDependencies += "com.github.joelittlejohn" % "jsonschema2pojo" % "jsonschema2pojo-1.2.2"
:dependencies [[com.github.joelittlejohn/jsonschema2pojo "jsonschema2pojo-1.2.2"]]
jsonschema2pojo generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x or Gson.
brew install jsonschema2pojo
You can use jsonschema2pojo as a Maven plugin, an Ant task, a command line utility, a Gradle plugin or embedded within your own Java app. The Getting Started guide will show you how.
A very simple Maven example:
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<targetPackage>com.example.types</targetPackage>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
A very simple Gradle example:
plugins {
id "java"
id "org.jsonschema2pojo" version "1.2.2"
}
repositories {
mavenCentral()
}
jsonSchema2Pojo {
targetPackage = 'com.example'
}
Useful pages:
Project resources:
Special thanks:
Licensed under the Apache License, Version 2.0.