Last active
January 2, 2016 07:09
-
-
Save ajduke/8267956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Example33 { | |
public static void main(String[] args) { | |
Gson gson = new GsonBuilder().setVersion(2.0).create(); | |
String json = gson.toJson(new ExampleClass()); | |
System.out.println("Output for version 2.0..."); | |
System.out.println(json); | |
gson= new GsonBuilder().setVersion(1.0).create(); | |
json = gson.toJson(new ExampleClass()); | |
System.out.println("\nOutput for version 1.0..."); | |
System.out.println(json); | |
gson= new Gson(); | |
json = gson.toJson(new ExampleClass()); | |
System.out.println("\nOutput for No version set..."); | |
System.out.println(json); | |
} | |
} | |
class ExampleClass{ | |
String field= "field"; | |
// this is in version 1.0 | |
@Since(1.0) String newField1 = "field 1"; | |
// following will be included in the version 1.1 | |
@Since(2.0) String newField2 = "field 2"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment