Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
Last active May 6, 2021 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tivrfoa/bb5deb269de39eb8fca9636dd3c9f123 to your computer and use it in GitHub Desktop.
Save tivrfoa/bb5deb269de39eb8fca9636dd3c9f123 to your computer and use it in GitHub Desktop.
Testing Gson
class AlbumImages {
public String image_id;
public String user_id;
public String albumId;
}
//SOURCES Dataset.java
import java.util.ArrayList;
import java.util.List;
class Albums {
public String title;
public String message;
public List errors = new ArrayList();
public String total;
public int total_pages;
public int page;
public String limit;
List<Dataset> dataset = new ArrayList<>();
}
//SOURCES AlbumImages.java
import java.util.ArrayList;
import java.util.List;
class Dataset {
public String album_id;
public String album_title;
List<AlbumImages> album_images = new ArrayList<AlbumImages>();
}
//DEPS com.google.code.gson:gson:2.8.6
//SOURCES Albums.java
import com.google.gson.Gson;
class GsonHelper {
static Gson gson = new Gson();
public static Albums getAlbums(String json) {
System.out.println("Getting Album: " + json);
return gson.fromJson(json, Albums.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment