@@ -0,0 +1,1789 @@
+import java.lang.reflect.Type;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.reflect.TypeToken;%0A%0A%0Apublic class main %7B%0A%09public static void main ( String%5B%5D args ) %7B%0A%09%09%0A%09%09fromVariableToJson();%0A%09%09fromJsonToVariable();%0A%09%7D%0A%0A%09private static void fromVariableToJson() %7B%0A%09%09Gson gson = new Gson();%0A%09%09%0A%09%09String data = %22One string to rule them all%22;%0A%09%09String json = gson.toJson(data);%0A%09%09%0A%09%09System.out.println(%22Value: %22 + json);%0A%09%09%0A%09%09int%5B%5D integers = new int%5B%5D %7B 1, 1, 3, 5, 8, 13 %7D;%0A%09%09json = gson.toJson(integers, int%5B%5D.class);%0A%09%09%0A%09%09System.out.println(%22Value: %22 + json);%0A%09%09%0A%09%09Person person = new Person();%0A%09%09json = gson.toJson(person, Person.class);%0A%09%09%0A%09%09System.out.println(%22Value: %22 + json);%0A%09%09%0A%09%09ArrayList%3CPerson%3E people = new ArrayList%3CPerson%3E();%0A%09%09people.add( new Person() );%0A%09%09people.add( new Person() );%0A%09%09%0A%09%09Type type = new TypeToken%3CList%3CPerson%3E%3E()%7B /**/ %7D.getType();%09%09%0A%09%09json = gson.toJson( people, type );%0A%09%09%0A%09%09System.out.println(%22Value: %22 + json);%0A%09%7D%0A%09%0A%09private static void fromJsonToVariable() %7B%0A%09%09Gson gson = new Gson();%0A%09%09%0A%09%09String json = %22%5C%22One string to rule them all%5C%22%22;%0A%09%09%0A%09%09String data = gson.fromJson(json, String.class);%0A%09%09System.out.println(%22Value: %22 + data);%0A%09%09%0A%09%09json = %22%5B1,1,3,5,8,13%5D%22;%0A%09%09%0A%09%09int%5B%5D integers = gson.fromJson(json, int%5B%5D.class);%0A%09%09%0A%09%09System.out.println(%22Value: %22 + integers);%0A%09%09%0A%09%09json = %22%7B%5C%22name%5C%22:%5C%22Miceal Gallagher%5C%22,%5C%22age%5C%22:27%7D%22;%0A%09%09Person person = gson.fromJson(json, Person.class);%0A%09%09%0A%09%09System.out.println(%22Value: %22 + person);%0A%09%09%0A%09%09json = %22%5B%7B%5C%22name%5C%22:%5C%22Miceal Gallagher%5C%22,%5C%22age%5C%22:27%7D,%7B%5C%22name%5C%22:%5C%22Miceal Gallagher%5C%22,%5C%22age%5C%22:27%7D%5D%22;%0A%09%09%0A%09%09Type type = new TypeToken%3CList%3CPerson%3E%3E()%7B /**/ %7D.getType();%0A%09%09List%3CPerson%3E people = gson.fromJson(json, type);%0A%09%09%0A%09%09System.out.println(%22Value: %22 + people);%0A%09%7D%0A%0A%7D%0A%0A

Rename file to GSONExample.java