Use GSON library for that. Here is the sample code

List<String> foo = new ArrayList<String>();
foo.add("A");
foo.add("B");
foo.add("C");

String json = new Gson().toJson(foo );

Here is the maven dependency for Gson

<dependencies>
    <!--  Gson: Java to Json conversion -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.2.2</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

Or you can directly download jar from here and put it in your class path

http://code.google.com/p/google-gson/downloads/detail?name=gson-1.0.jar&can=4&q=

To send Json to client you can use spring or in simple servlet add this code

response.getWriter().write(json);

Answer from code_fish 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 corresponding field. In this article, we discussed how to convert a JSON array to a Java List using two popular libraries: Gson and Jackson.
๐ŸŒ
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 - In addition to external libraries like Gson and Jackson, Java also provides a built-in library called org.json for JSON processing. To convert a Java List to a JSON array using org.json, we can use the JSONArray class to accomplish this task.
Discussions

How to convert list data into json in java - Stack Overflow
I have a function which is returning Data as List in java class. Now as per my need, I have to convert it into Json Format. Below is my function code snippet: public static List More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to convert JSON string into List of Java object? - Stack Overflow
String list = "your_json_string"; ... , listType); ... "No need to use any library"... but you're very clearly using GSON (which already has an answer provided above)?! 2020-04-14T09:19:34.517Z+00:00 ... I made a method to do this below called jsonArrayToObjectList. Its a handy static class that will take a filename and the file contains an array in JSON ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
java - JSON: Get list of JSON Objects - Stack Overflow
For more info, please refer to the docs on JSONArray and JSONObject. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to parse json to get size of the list using jsonObject in java?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
๐ŸŒ r/javahelp
4
1
May 16, 2022
๐ŸŒ
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 - Following is the code to convert a list to a JSON array using the Jackson library: import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import java.util.Arrays; import java.util.List; public class ListToJsonArrayJackson { public static void main(String[] args) throws Exception { List<String> list = Arrays.asList("apple", "banana", "cherry"); ObjectMapper mapper = new ObjectMapper(); ArrayNode arrayNode = mapper.valueToTree(list); System.out.println("JSON Array: " + arrayNode.toPrettyString()); } }
๐ŸŒ
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.databind.ObjectMapper; import com.mkyong.json.model.Person; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; public class JsonArrayToObjectExample3 { public static void main(String[] args) throws JsonProcessingException { // Create a list of Person objects List<Person> people = Arrays.asList( new Person("mkyong", 42), new Person("ah pig", 20) ); // Wrap the list in a Map with "Person" as the key Map<String, List<Person>> wrapper
Find elsewhere
๐ŸŒ
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]
๐ŸŒ
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 - We don't always deal with JSON in String format. Oftentimes, the contents come from a File. Thankfully, Jackson makes this task as easy as the last one, we just provide the File to the readValue() method: final ObjectMapper objectMapper = new ObjectMapper(); List<Language> langList = objectMapper.readValue( new File("langs.json"), new TypeReference<List<Language>>(){}); langList.forEach(x -> System.out.println(x.toString())); ... [ { "name": "Java", "description": "Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible."
๐ŸŒ
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 - The writeValueAsString() method of the ObjectMapper class serializes a given Java object, such as a List or ArrayList, into JSON-formatted String.
๐ŸŒ
Java Code Geeks
javacodegeeks.com โ€บ home โ€บ core java
Converting JSON Array to Java List with Gson - Java Code Geeks
April 25, 2024 - Gson, a cornerstone Java library for JSON parsing, stands ready to streamline this conversion process. In this comprehensive guide, we delve into various strategies for seamlessly transforming a JSON array into an equivalent java.util.List object using Gson.
๐ŸŒ
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 - In this short tutorial, you'll learn how to use the Jackson library to convert a JSON array string into a list of Java Objects and vice versa.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ convert-a-list-of-objects-to-json-using-the-gson-library-in-java
Convert a list of objects to JSON using the Gson library in Java?
April 22, 2025 - import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import java.util.ArrayList; import java.util.List; public class ListToJsonTree { public static void main(String[] args) { // Create a list of objects List<Person> personList = new ArrayList<>(); personList.add(new Person("Ansh", 23)); personList.add(new Person("Bam", 17)); personList.add(new Person("Ace", 22)); // Create a Gson instance Gson gson = new Gson(); // Convert the list to JSON array JsonElement jsonElement = gson.toJsonTree(personList); JsonArray jsonArray = jsonElement.getAsJsonArray(); // Convert the JSON array to string String jsonString = jsonArray.toString(); // Print the JSON string System.out.println(jsonString); } }
๐ŸŒ
Java Guides
javaguides.net โ€บ 2019 โ€บ 07 โ€บ convert-list-to-json-array-using-jackson.html
Convert List to JSON Array Using Jackson
July 21, 2019 - In this quick article, I will show how to convert a List to JSON array using Jackson. Check out complete Jackson tutorial at Java Jackson JSON Tutorial with Examples. We are using Jackson library to convert Java List to JSON array so let's add below Jackson dependency to your project's classpath ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-can-we-convert-a-json-array-to-a-list-using-jackson-in-java
How can we convert a JSON array to a list using Jackson in Java?\\n
June 5, 2025 - import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; import java.io.IOException; import java.util.ArrayList; public class JsonArrayToList{ public static void main(String[] args) { String jsonArray = "[{"name":"John","age":30},{"name":"Jane","age":25}]"; ObjectMapper objectMapper = new ObjectMapper(); try { List<Person> personList = objectMapper.readValue(jsonArray, new TypeReference<List<Person>>(){}); for (Person person : personList) { System.out.println("Name: " + person.getName() + ", Age: " + person.getAge()); } }
๐ŸŒ
DevGenius
blog.devgenius.io โ€บ how-to-convert-a-java-list-to-a-json-array-a-simple-guide-d3428951a488
How to Convert a Java List to a JSON Array: A Simple Guide | by M Business Solutions | Dev Genius
December 5, 2024 - Fortunately, converting a Java List to a JSON array is straightforward with the help of libraries like Jackson or Gson. In this blog, weโ€™ll walk through different methods for converting a Java List into a JSON array and explore the best practices for handling this conversion.
๐ŸŒ
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 - Here we are adding the logic of converting an ArrayList of objects to a JSON array of Java in the main class. ... 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(); } } }
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 713115 โ€บ java โ€บ conversion-array-list-Json-object
conversion of array list to Json object string (Java in General forum at Coderanch)
July 19, 2019 - programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums ยท this forum made possible by our volunteer staff, including ... ... Hi I have two lists Edge1List and Edge2List which I add to element on them. Edge1List:[o,p] and Edge2List: [p,null]. I convert Edge1List and Edge2List to JsonArray with the name of EdgeJsonArray1 and EdgeJsonArray2 respectively.