Convert a JSON array to a List using Jackson

In this post we will provide an example of how to convert a JSON array to a List using Jackson.

Setup:

In this example you will need to add the following dependancy

Convert a JSON array to a list:

The example below shows how to convert a JSON array to a java list using Jackson.

As you can see from the above example, the ObjectMapper class has a useful method readValue which takes a JSON string and converts it to the object class you specify as the 2nd argument (in this case a List)

Output:

Running the above code produces the following output

In conclusion I hope the you found this post useful

Similar posts:

  1. Convert a list to json array using Jackson
  2. How to convert a java object to json using Jackson
  3. How to parse JSON using Jackson
  4. How to parse a JSON string to a object using Jackson

References:

  1. Jackson documentation

 

Leave a Reply