1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//String containing Json pulled from web service
String response = webService.webGet("", params);

//   Content of response:
//   [
//     {"article":
//       { "author_id":9,
//         "body":"The East Baton Rouge Parish District Attorney's Office will...",
//         "category":"news",
//         "created_at":"2011-06-14T16:54:01-05:00",
//         "id":1948,
//         "published":"2011-06-14T16:52:00-05:00",
//         "updated_at":"2011-06-14T16:54:01-05:00"
//       }
//     },
//     {"article":
//       { "author_id":183,
//         "body":"Students can now find the perfect...",
//         "category":"news",
//         "created_at":"2011-06-14T16:53:05-05:00",
//         "id":1947,
//         "published":"2011-06-14T16:52:00-05:00",
//         "updated_at":"2011-06-14T16:53:05-05:00"
//       }
//     }
//     ...
//   ]

try {
     //Specifying the structure of the variable to be parsed into
     Type collectionType = new TypeToken<ArrayList<Article>>(){}.getType();

     //Variable to be parsed into
     ArrayList<Article> articles=null;

     //Filling the variable with Gson's parsing, error occurs here
     articles = new Gson().fromJson(response, collectionType);

catch(Exception e) {
     Log.d("Error: ", e.getMessage());
}