A simple Java Util wrapper over jackson-binding for converting json to any object type and vice-versa.
Use the toJson(T)
method to convert any object of type T
to JSON.
Coordinates coordinates = new Coordinates(10, 20, 30);
Yoru<Coordinates> converter = new Yoru<>();
converter.toJson(coordinates);
Result:
{
"x" : 10.0,
"y" : 20.0,
"z" : 30.0
}
Use the fromJson(String content)
method to convert json to any type T
.
Yoru<Coordinates> converter = new Yoru<>();
Coordinates coordinates = converter.fromJson(toJsonExpectation, Coordinates.class);
This library can be used with both maven and gradle build environments. See instructions below for more details on how to add this to your project.
Step 1. Add the JitPack repository to your build file
maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
maven
<dependency>
<groupId>com.github.nextbss</groupId>
<artifactId>yoru</artifactId>
<version>1.0.2</version>
</dependency>
gradle
dependencies {
implementation 'com.github.nextbss:yoru:1.0.2'
}
The library is available as open source under the terms of the MIT License.