Skip to content

mooqoo/Gson-Json

Repository files navigation

Gson-Json

An Android sample code that convert data between json and java object using both Android's JSONObject and Google's gson. This sample code is based on this tutorial and modifed to test the conversion between json and java object with nested object.

Three Custom Class was created and used:

  • Albums (Contains a List of Dataset)
  • Dataset (Contains a List of AlbumImages)
  • AlbumImages

Below is the layout of this sample app:

app layout

Reset Object Button

By pressing this button, a new Albums object will be created with random values.

Gson Section :

To JSON: this button will convert album object to json using gson library.
PARSING: this button will convert json data back to album object using gson library.

JSONObject Section :

An JSONUtil Class was created and used to handle all the json conversion using Android's JSONObject library.
To JSON: this button will convert album object to json using JSONUtil(JSONObject).
PARSING: this button will convert json data back to album object using JSONUtil(JSONObject).

Gradle:

  • ButterKnife (compile 'com.jakewharton:butterknife:7.0.1')
  • Gson (compile 'com.google.code.gson:gson:2.3.1')

About

An Android sample code that implements google's gson library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages