Last active
December 20, 2015 08:09
-
-
Save ajduke/6098733 to your computer and use it in GitHub Desktop.
This file contains 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
Gson gson = new Gson(); | |
// original object | |
ModelObject modelObject = new ModelObject("namesake", 50, true, 4.3); | |
System.out.print("Original Java object : "); | |
System.out.println(modelObject); | |
// converting to an json representation | |
String json = gson.toJson(modelObject); | |
System.out.print("Converted JSON string is : "); | |
System.out.println(json); | |
// getting back the object from json representation | |
ModelObject modelObject3 = gson.fromJson(json, ModelObject.class); | |
System.out.print("Converted Java object : "); | |
System.out.println(modelObject3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment