Skip to content

Instantly share code, notes, and snippets.

@ajduke

ajduke/Example33.java

Last active Jan 2, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.