Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.15 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.15 KB

Type adapter to support polymorphic deserialization with Gson

For a high level overview refer to my blog.

Compile and Test Maven Central

Usage

Refer to the maven artifact

<dependency>
	<groupId>com.github.ruediste</groupId>
	<artifactId>polymorphic-gson</artifactId>
	<version>...</version>
</dependency>

Then register the type adapter when you create your Gson instance:

new GsonBuilder().registerTypeAdapterFactory(
	PolymorphStyle.TYPE_PROPERTY,
	getClass().getClassLoader(), 
	"your.package.prefix.to.scan"))
	...
	.create();

Releasing

Use

mvn versions:set -DnewVersion=0.1

Push to the release branch. A github action will automatically pick this up and publish the artifacts. Then run a

mvn versions:set -DnewVersion=0.2-SNAPSHOT

and push to master.