A utility for automatic conversion to and from json using gson.
You will need gson in your class path as autogson does not include it.
//Create a gson instance
//To get json
String json = new AutoGson.Builder().build().toJson(gson, object);
//From json
FooBar bar = new AutoGson.Builder().build().fromJson(gson, json);
repositories {
maven { url 'https://jitpack.io' }
}
compile 'com.github.ravenlab:autogson:2.0.0'
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.ravenlab</groupId>
<artifactId>autogson</artifactId>
<version>2.0.0</version>
</dependency>
When creating a json string a seperate field in the json with the class's name is created.
When deserializing from json the new field is used to find the class via reflection to create your new object.
Since the class name is stored if the class is missing or refactored to a new class path autogson will not be able to deserialize your object.