import com.google.gson.Gson; public class App { public static void main(String[] args) throws Exception { Employee emp = new Employee("Csendes Imre", "Szeged", 342); Gson gson = new Gson(); String jsonStr = gson.toJson(emp); Employee empCopy = gson.fromJson(jsonStr, Employee.class); System.out.println(empCopy.name); System.out.println(empCopy.city); System.out.println(empCopy.salary); } }