ArrayList<String> listdata = new ArrayList<String>();     
JSONArray jArray = (JSONArray)jsonObject; 
if (jArray != null) { 
   for (int i=0;i<jArray.length();i++){ 
    listdata.add(jArray.getString(i));
   } 
} 
Answer from Sagar Maiyad on Stack Overflow
🌐
Baeldung
baeldung.com › home › json › jackson › convert json array to java list
Convert JSON Array to Java List | Baeldung
August 13, 2025 - Then, we use the readValue() method of the ObjectMapper object to convert the JSON array String to a List. Similar to the assertion discussed previously, finally, we compare a specific field from the String JSON array to the jacksonList ...
Top answer
1 of 16
204
ArrayList<String> listdata = new ArrayList<String>();     
JSONArray jArray = (JSONArray)jsonObject; 
if (jArray != null) { 
   for (int i=0;i<jArray.length();i++){ 
    listdata.add(jArray.getString(i));
   } 
} 
2 of 16
85

I've done it using Gson (by Google).

Add the following line to your module's build.gradle:

dependencies {
  // ...
  // Note that `compile` will be deprecated. Use `implementation` instead.
  // See https://stackoverflow.com/a/44409111 for more info
  implementation 'com.google.code.gson:gson:2.8.2'
}

JSON string:

private String jsonString = "[\n" +
            "        {\n" +
            "                \"id\": \"c200\",\n" +
            "                \"name\": \"Ravi Tamada\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c201\",\n" +
            "                \"name\": \"Johnny Depp\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c202\",\n" +
            "                \"name\": \"Leonardo Dicaprio\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c203\",\n" +
            "                \"name\": \"John Wayne\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c204\",\n" +
            "                \"name\": \"Angelina Jolie\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"female\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c205\",\n" +
            "                \"name\": \"Dido\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"female\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c206\",\n" +
            "                \"name\": \"Adele\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"female\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c207\",\n" +
            "                \"name\": \"Hugh Jackman\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c208\",\n" +
            "                \"name\": \"Will Smith\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c209\",\n" +
            "                \"name\": \"Clint Eastwood\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c2010\",\n" +
            "                \"name\": \"Barack Obama\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c2011\",\n" +
            "                \"name\": \"Kate Winslet\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"female\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        },\n" +
            "        {\n" +
            "                \"id\": \"c2012\",\n" +
            "                \"name\": \"Eminem\",\n" +
            "                \"email\": \"[email protected]\",\n" +
            "                \"address\": \"xx-xx-xxxx,x - street, x - country\",\n" +
            "                \"gender\" : \"male\",\n" +
            "                \"phone\": {\n" +
            "                    \"mobile\": \"+91 0000000000\",\n" +
            "                    \"home\": \"00 000000\",\n" +
            "                    \"office\": \"00 000000\"\n" +
            "                }\n" +
            "        }\n" +
            "    ]";

ContactModel.java:

public class ContactModel {
     public String id;
     public String name;
     public String email;
}

Code for converting a JSON string to ArrayList<Model>:

Note: You have to import java.lang.reflect.Type;:

// Top of file
import java.lang.reflect.Type;

// ...

private void parseJSON() {
    Gson gson = new Gson();
    Type type = new TypeToken<List<ContactModel>>(){}.getType();
    List<ContactModel> contactList = gson.fromJson(jsonString, type);
    for (ContactModel contact : contactList){
        Log.i("Contact Details", contact.id + "-" + contact.name + "-" + contact.email);
    }
}

Hope this will help you.

🌐
Baeldung
baeldung.com › home › java › java list › converting a java list to a json array
Converting a Java List to a Json Array | Baeldung
June 18, 2025 - Now, we’ll use the Gson library to convert the Java List to a JSON array. Here’s a test method: @Test public void given_JavaList_whenUsingGsonLibrary_thenOutJsonArray() { Gson gson = new Gson(); String jsonArray = gson.toJson(list); ...
🌐
TutorialsPoint
tutorialspoint.com › how-can-we-convert-a-list-to-the-json-array-in-java
How can we convert a list to the JSON array in Java?
April 22, 2025 - The following is the code to convert a list to a JSON array using the org.json library: import org.json.JSONArray; import java.util.Arrays; import java.util.List; public class ListToJsonArrayOrg { public static void main(String[] args) { List<String> list = Arrays.asList("apple", "banana", "cherry"); JSONArray jsonArray = new JSONArray(list); System.out.println("JSON Array: " + jsonArray.toString(2)); } }
🌐
TutorialsPoint
tutorialspoint.com › how-to-convert-java-array-or-arraylist-to-jsonarray-using-gson-in-java
How to convert Java array or ArrayList to JsonArray using Gson in Java?
We can convert an array or ArrayList to JsonArray using the toJsonTree().getAsJsonArray() method of Gson class. public JsonElement toJsonTree(java.lang.Object src) import com.google.gson.*; import java.util.*; public class JavaArrayToJsonArrayTest { public static void main(String args[]) { ...
🌐
Quora
quora.com › How-do-I-convert-a-list-to-JSON-in-Java
How to convert a list to JSON in Java - Quora
Answer (1 of 8): Just use ObjectMapper from fasterxml library. [code]import com.fasterxml.jackson.databind.ObjectMapper; ObjectMapper mapper = new ObjectMapper(); String jsonString = mapper.writeValueAsString(anyObject); [/code]
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › how-to-convert-a-list-to-json-array-using-the-jackson-library-in-java
How to convert a List to JSON array using the Jackson library in Java?
April 29, 2025 - import java.util.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.node.ArrayNode; public class ListToJSONArrayUsingArrayNode { public static void main(String[] args) { List < String > list = Arrays.asList("JAVA", "PYTHON", "SCALA", ".NET", "TESTING"); ObjectMapper objectMapper = new ObjectMapper(); ArrayNode arrayNode = objectMapper.createArrayNode(); for (String item: list) { arrayNode.add(item); // adding each item manually } try { String jsonArray = objectMapper.writeValueAsString(arrayNode); System.out.println(jsonArray); } catch (Exception e) { e.printStackTrace(); } } } [ "JAVA", "PYTHON", "SCALA", ".NET", "TESTING" ] Manisha Chand ·
🌐
Google Groups
groups.google.com › g › vertx › c › 5fgz-e2rTbk
casting a JsonArray to a specific type
The Java 8 Stream API, in combination with lambdas, is so useful. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... In case someone is interested, when it is a more complex type. JsonArray jarr = new JsonArray(messageAsyncResult.result().bodyAsString()); List<Customer> cl = (List<Customer>) jarr.getList().stream().map(s ->
🌐
How to do in Java
howtodoinjava.com › home › convert json array to list: gson, jackson and org.json
Convert JSON Array to List: Gson, Jackson and Org.json
September 25, 2023 - In Java, due to type erasure, the generic type information of collections (like List<T>) is not available at runtime. So Gson doesn’t know the exact type we want to deserialize to when dealing with generic types. The TypeToken class retains this information and acts as a workaround for the limitations of type erasure. List<Person> readPersonListFromJsonArray(String jsonArray) { //Use autowired bean in Spring / Spring Boot Gson gson = new Gson(); Type listType = new TypeToken<List<Person>>() {}.getType(); List<Person> personList = gson.fromJson(jsonArray, listType); return personList; }
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-an-arraylist-of-objects-to-a-json-array-in-java
How to Convert an ArrayList of Objects to a JSON Array in Java? - GeeksforGeeks
July 23, 2025 - package org.example; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { // Create an ArrayList of objects List<Course> courses = new ArrayList<>(); courses.add( new Course(1, "Java", "25000", "3 Months")); courses.add( new Course(2, "C++", "20000", "3 Months")); // Convert the ArrayList to a JSON array ObjectMapper objectMapper = new ObjectMapper(); try { String jsonArray = objectMapper.writeValueAsString(courses); System.out.println(jsonArray); } catch (JsonProcessingException e) { e.printStackTrace(); } } }
🌐
Stack Abuse
stackabuse.com › converting-json-array-to-a-java-array-or-list
Convert JSON Array to a Java Array or List with Jackson
September 8, 2020 - In this tutorial, we'll use Jackson with Java to convert a JSON array into a Java array and a Java List with examples. This can be done from Strings or Files.
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Converting JSON Array to Java List with Gson - Java Code Geeks
April 25, 2024 - String json = "[{\"name\":\"John\"},{\"name\":\"Doe\"}]"; JsonArray jsonArray = JsonParser.parseString(json).getAsJsonArray(); List<MyObject> list = new ArrayList<>(); for (JsonElement element : jsonArray) { MyObject obj = new Gson().fromJson(element, MyObject.class); list.add(obj); } We parse a JSON array into a JsonArray using Gson’s JsonParser. Then, we iterate over each element of the array, converting them into Java objects using Gson’s fromJson() method. Finally, we add each Java object to a List.
🌐
Attacomsian
attacomsian.com › blog › jackson-convert-json-array-to-from-java-list
Convert JSON array to a list using Jackson in Java
November 6, 2022 - The following example demonstrates how to use the writeValueAsString() method from the ObjectMapper class to convert a list of Java Objects to their JSON array representation:
🌐
MIT App Inventor
community.appinventor.mit.edu › open source development › extension development
List to JSONArray - Extension Development - MIT App Inventor Community
May 11, 2024 - Any one know List to JSONArray in java I have a variable in list format I want to convert it to json array how ?
🌐
Mkyong
mkyong.com › home › java › how to parse json array with jackson
How to parse JSON Array with Jackson - Mkyong.com
April 23, 2024 - convert JSON array to Array objects Person[] person1 = mapper.readValue(jsonArray, Person[].class); for (Person p : person1) { System.out.println(p); } // 2. convert JSON array to List List<Person> person2 = mapper.readValue(jsonArray, new TypeReference<>() { }); person2.forEach(System.out::println); } } ... Person{name='mkyong', age=42} Person{name='ah pig', age=20} Person{name='mkyong', age=42} Person{name='ah pig', age=20} ... package com.mkyong.json.jackson; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.mkyong.json