/Gson-Polymorphism-Example

A simple Gson polymorphism serialization and deserialization example by using TypeAdapterFactory.

Primary LanguageJavaMIT LicenseMIT

Gson-Polymorphism-Example

Java8 build

  • A simple Gson polymorphism serialization and deserialization example by using TypeAdapterFactory.
  • Modified from stack overflow

How to use

$ git clone https://github.com/dyhe83/Gson-Polymorphism-Example.git --depth=1
$ cd Gson-Polymorphism-Example
$ ./gradlew run

[Animal]
Numbers of foot = 0

[Bird]
Numbers of foot = 2
Numbers of eye  = 2

[Cat]
Numbers of foot = 4
Numbers of tail = 1