-
-
Save maxandersen/c3cad44ca6620de7e5a3abb8a98879a9 to your computer and use it in GitHub Desktop.
Testing Gson
This file contains hidden or 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
class AlbumImages { | |
public String image_id; | |
public String user_id; | |
public String albumId; | |
} |
This file contains hidden or 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
//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<>(); | |
} |
This file contains hidden or 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
//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>(); | |
} |
This file contains hidden or 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
//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