How to parse a JSON array into a List with Gson

In this tutorial we will show you how to parse a JSON array into a List using GSON.

Setup:

For this example you will need to add the following dependancy to your project

And the following class, which represents the JSON array.

How to parse a JSON array into a List:

Below is an example of how to convert a JSON array into a typed Java list.

Running the above code produces the following output

Output:

In conclusion I hope you found this post useful in parsing JSON to a java list.

Similar posts:

  1. How to convert a Java object to JSON
  2. How to convert JSON string to Java object
  3. How to parse a JSON file

References:

  1. GSON Documentation

Leave a Reply