ArrayList<String> list = new ArrayList<String>();     
JSONArray jsonArray = (JSONArray)jsonObject; 
if (jsonArray != null) { 
   int len = jsonArray.length();
   for (int i=0;i<len;i++){ 
    list.add(jsonArray.get(i).toString());
   } 
} 
Answer from Pentium10 on Stack Overflow
🌐
Stleary
stleary.github.io › JSON-java › org › json › JSONArray.html
JSONArray
If an element in the array is a JSONArray or JSONObject it will also be converted to a List and a Map respectively.
🌐
Tabnine
tabnine.com › home page › code › java › org.json.jsonarray
org.json.JSONArray.toList java code examples | Tabnine
origin: com.github.everit-org.json-schema/org.everit.json.schema · static Object toJavaValue(Object orig) { if (orig instanceof JSONArray) { return ((JSONArray) orig).toList(); } else if (orig instanceof JSONObject) { return ((JSONObject) orig).toMap(); } else { return orig; } } origin: ru.curs/celesta-sql · /** * Returns array for {@code key} as a value list.
🌐
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 - 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; } Org.json or JSON-Java is a simple and lightweight Java-based library that we can use to encode or decode between JSON and XML, HTTP headers, Cookies, and CDL.
Top answer
1 of 16
203
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.

🌐
TutorialsPoint
tutorialspoint.com › org_json › org_json_jsonarray.htm
Org.Json - HTTP Class
package com.tutorialspoint; import org.json.JSONArray; import org.json.JSONObject; public class JsonDemo { public static void main(String[] args) { JSONArray list = new JSONArray(); list.put("foo"); list.put(Integer.valueOf(100)); list.put(Double.valueOf(1000.21)); list.put(Boolean.TRUE); list.put(JSONObject.NULL); System.out.println("JSONArray: "); System.out.println(list); } }
🌐
Android Developers
developer.android.com › api reference › jsonarray
JSONArray | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Oracle
docs.oracle.com › javaee › 7 › api › javax › json › JsonArray.html
JsonArray (Java(TM) EE 7 Specification APIs)
It also provides an unmodifiable list view of the values in the array. A JsonArray object can be created by reading JSON data from an input source or it can be built from scratch using an array builder object. The following example demonstrates how to create a JsonArray object from an input source using the method JsonReader.readArray():
🌐
Baeldung
baeldung.com › home › json › jackson › convert json array to java list
Convert JSON Array to Java List | Baeldung
August 13, 2025 - Now that we have the JSON array, let’s try to understand its conversion to a List: @Test public void whenUsingGsonLibrary_thenCompareTwoProducts() { Gson gson = new Gson(); Type listType = new TypeToken<List<Product>>() {}.getType(); List<Product> gsonList = gson.fromJson(jsonArray, listType); Assert.assertEquals(1, gsonList.get(0).getId()); Assert.assertEquals("Sweet and cold", gsonList.get(0).getDescription()); Assert.assertEquals("Icecream", gsonList.get(0).getName()); } First, we need to create an instance of the Gson class, which provides methods for JSON serialization and deserialization.
Find elsewhere
🌐
Mkyong
mkyong.com › home › java › how to parse json array with jackson
How to parse JSON Array with Jackson - Mkyong.com
April 23, 2024 - package com.mkyong.json.jackson; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.mkyong.json.model.Person; import java.util.List; public class JsonArrayToObjectExample { public static void main(String[] args) throws JsonProcessingException { String jsonArray = "[{\"name\":\"mkyong\", \"age\":42}, {\"name\":\"ah pig\", \"age\":20}]"; ObjectMapper mapper = new ObjectMapper(); // 1.
🌐
GitHub
github.com › stleary › JSON-java › blob › master › src › main › java › org › json › JSONArray.java
JSON-java/src/main/java/org/json/JSONArray.java at master · stleary/JSON-java
package org.json; · /* Public Domain. */ · import java.io.IOException; import java.io.Writer; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; · · /** * A JSONArray is an ordered sequence of values.
Author   stleary
🌐
Baeldung
baeldung.com › home › json › introduction to json-java (org.json)
Introduction to JSON-Java (org.json)
June 20, 2025 - We simply pass them as an argument ... object: List<String> list = new ArrayList<>(); list.add("California"); list.add("Texas"); list.add("Hawaii"); list.add("Alaska"); JSONArray ja = new JSONArray(list);...
🌐
SourceForge
json-lib.sourceforge.net › apidocs › net › sf › json › JSONArray.html
JSONArray (Overview (json-lib jdk 1.3 API))
public static Collection toCollection(JSONArray jsonArray, JsonConfig jsonConfig) Returns a List or a Set taking generics into account.
🌐
TutorialsPoint
tutorialspoint.com › org_json › org_json_quick_guide.htm
Org.Json - Quick Guide
It provides methods to access values by index and to put values. Following types are supported − ... package com.tutorialspoint; import org.json.JSONArray; public class JsonDemo { public static void main(String[] args) { JSONArray list = new JSONArray(); list.put("Apple"); list.put("Banana"); list.put("Orange"); list.put("Mango"); list.put("Guava"); System.out.println("JSONArray: "); System.out.println(list); } }
🌐
GitHub
github.com › Microsoft › spring-data-cosmosdb › issues › 22
java.lang.ClassCastException: Cannot cast org.json.JSONArray to List · Issue #22 · microsoft/spring-data-cosmosdb
December 15, 2017 - java.lang.ClassCastException: Cannot cast org.json.JSONArray to List#22 · Copy link · Labels · feature · verhcedr · opened · on Dec 15, 2017 · Issue body actions ·
Author   verhcedr
🌐
GitHub
github.com › stleary › JSON-java › issues › 674
Suggestion: JSONArray#toList(class) · Issue #674 · stleary/JSON-java
jarr.toList().stream().map(Object::toString).toList(); // List of string jarr.toList().stream().map(o -> (JSONObject) o).toList(); // List of JSONObject · I wrote a function that implments this, but I'm not too Java experty to know if it's ideal: /** * Converts a JSONArray to a list of {@code <T>}. * * @param array The JSONArray * @param cast The class to cast to * @param <T> The type to cast to * @return A list of {@code <T>} */ public static <T> List<T> toList(JSONArray array, Class<T> cast) { List<T> results = new ArrayList<>(array.length()); for (Object element : array) { if (element == null || JSONObject.NULL.equals(element)) { results.add(null); } else { results.add(cast.cast(element)); } } return results; }
🌐
Javadoc.io
javadoc.io › doc › org.json › json › 20171018 › org › json › JSONArray.html
JSONArray (JSON in Java 20171018 API)
https://javadoc.io/doc/org.json/json/20171018 · package-list path (used for javadoc generation -link option) https://javadoc.io/doc/org.json/json/20171018/package-list ·