Last active
July 8, 2016 09:24
-
-
Save Heroes84/c06d40c73cc19077beaf29eb81d5ed5d to your computer and use it in GitHub Desktop.
GSON TypeToken
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
/get json array from json string | |
JsonArray jarray = jobject.getAsJsonArray("reportRecords"); | |
//get a list of reportRecords using Gson | |
Gson mGson = new Gson(); | |
Type listType = new TypeToken<List<DataMetrics>>(){}.getType(); | |
List<DataMetrics> dataMetricsList = mGson.fromJson(reportRecordsJsonArray, listType); | |
//Filter only the ones with a specific name | |
List<DataMetrics> dataMetricsFilteredList = dataMetricsList.stream().filter(dataMetric -> dateMetric.getName.equals("Client::Sync")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment