You are asking Jackson to parse a StudentList. Tell it to parse a List (of students) instead. Since List is generic you will typically use a TypeReference

List<Student> participantJsonList = mapper.readValue(jsonString, new TypeReference<List<Student>>(){});
Answer from Manos Nikolaidis 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 fromJson() method of the Gson object to convert the JSON array String to a List. Since we’ve converted JSON array to a List, let’s also try to analyze the assertion.
Discussions

Converting a JSON string into an object with a list of objects inside it - Java - Stack Overflow
How do I "unpack" the JSON into ... objects as its attributes? (Ideally, it would be using the Gson library) ... Gson gson = new Gson(); Type listType = new TypeToken>(){}.getType(); List tokenList = gson.fromJson(jsonString, listType); System.out.println(tokenList.get(0)); ... Well ... What did reading the documentation tell you? ... import java.util.List; ... More on stackoverflow.com
🌐 stackoverflow.com
json - How to convert automatically list of objects to JSONArray with Gson library in java? - Stack Overflow
Lets say I have following list of custom object: ArrayList where GroupItem is some class that has int and String variables. I tried so far Gson library but it's not exactly what ... More on stackoverflow.com
🌐 stackoverflow.com
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
android - Convert JSON String to List of Java Objects - Stack Overflow
The main idea is to populate each JSON object into the Java Class then into an array of SomeObject. More on stackoverflow.com
🌐 stackoverflow.com
January 13, 2018
🌐
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()); } }
🌐
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
🌐
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 - Now we can use the readValue() method from the ObjectMapper class to transform the above JSON array to a list of User objects, as shown below: try { // JSON array String json = "[{\"name\":\"John Doe\",\"email\":\"john.doe@example.com\"," + ...
🌐
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 - The following code parses a JSON array containing person data and converts it into a list of Java Person objects using the JSONArray and JSONObject classes.
🌐
Makeinjava
makeinjava.com › home › convert list of objects to/from json in java (jackson objectmapper/ example)
Convert list of objects to/from JSON in java (jackson objectmapper/example)
January 1, 2024 - We will use the jackson’s objectmapper, to serialize list of objects to JSON & deserialize JSON to List of objects. We will create Person class & we will perform following operations with Person class. ... Convert the JSON to List of Person objects.
Find elsewhere
🌐
HowToDoInJava
howtodoinjava.com › home › gson › gson – parse json array to java array or list
Gson - Parse JSON Array to Java Array or List
April 4, 2023 - Here ArrayItem is the class type of data elements in the array. ArrayItem[] userArray = new Gson().fromJson(jsonSource, ArrayItem[].class); For converting such JSON array to a List, we need to use TypeToken class.
🌐
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 - 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."
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Converting JSON Array to Java List with Gson - Java Code Geeks
April 25, 2024 - Then, we use Gson’s fromJson() method, passing the JSON string and the Type object, to deserialize the JSON array into a Java List. This approach leverages Guava’s utilities for Gson conversions, offering similar functionality to Gson’s TypeToken approach. For the intrepid developer grappling with more intricate scenarios, the Java Reflection API proffers a potent toolset. Dynamically crafting a ParameterizedType encapsulating the List type with the desired element type affords unparalleled flexibility. To convert a JSON array to a List using ParameterizedType from the Java Reflection API, you need to follow these steps:
🌐
Java Tech Blog
javanexus.com › blog › converting-json-array-to-java-list-gson-nested-objects
Converting JSON Array to Java List with Gson: Handling Nested Objects | Java Tech Blog
May 9, 2024 - We use fromJson method to deserialize the JSON array string into a List of Person objects. Gson automatically handles the deserialization of nested objects as long as the structure of the JSON matches the structure of the Java objects.
Top answer
1 of 5
1

Your input string should be as follows to qualify for a list of SomeObject

{
    [{
            "k1": 1,
            "k2": "v2",
            "k3": "v3"
        }, {
            "k1": 2,
            "k2": "v2",
            "k3": "v3"
        }
    ]
}

Below code should work ..

JSONObject jsonObject = new JSONObject(jsonString);
SomeObject[] objectsList = gson.fromJson(jsonObject.toString(), SomeObject[].class);

For given JSON String here you can handle this way (add toString() to SomeObject for displaying it)...

import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

public class TestClass {

    public static void main(String[] args) {
        List<SomeObject> list = new LinkedList<SomeObject>();
        String jsonString = "{\"obj_1\":{\"k1\":1,\"k2\":\"v2\",\"k3\":\"v3\"},\"obj_2\":{\"k1\":2,\"k2\":\"v2\",\"k3\":\"v3\"}}";
        Gson gson = new Gson();
        JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
        for (Entry<String, JsonElement> entry : jsonObject.entrySet()) {
            // note entry.getKey() will be obj_1, obj_2, etc.
            SomeObject item = gson.fromJson(entry.getValue().getAsJsonObject(), SomeObject.class);
            list.add(item);
        }
        System.out.println(list);
    }
}

Sample Run

[SomeObject [k1=1, k2=v2, k3=v3], SomeObject [k1=2, k2=v2, k3=v3]]

NOTE: the value of k1 must be a number and without quotes as k1 is declared as int in SomeObject

2 of 5
0

Your JSON structure is a Map, if you want an array or list use [ { } , {} ] it is the structure in JSON for array or list

Top answer
1 of 1
6

You can convert the result to an object list, or you can pass in a type parameter rather than the List class.

String jsonString = "[{\"id\": \"0\", \"ip\": \"123\", \"mac\": \"456\"}, {\"id\": \"1\", \"ip\": \"111\", \"mac\": \"222\"}]";

With Object

List<Object> items = objectMapper.readValue(
    jsonString,
    objectMapper.getTypeFactory().constructParametricType(List.class, Object.class)
);

With SlaveEntity

List<SlaveEntity> items = objectMapper.readValue(
    jsonString,
    objectMapper.getTypeFactory().constructCollectionType(List.class, SlaveEntity.class)
);

Update

This is what I have come up with, and it works.

EntityTest

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;

public class EntityTest {
    public static void main(String[] args) {
        String json = "[{\"id\": \"0\", \"ip\": \"123\", \"mac\": \"456\"}, {\"id\": \"1\", \"ip\": \"111\", \"mac\": \"222\"}]";

        for (SlaveEntity entity : jsonToSlaveEntity(json)) {
            System.out.println(entity);
        }
    }

    public static List<SlaveEntity> jsonToSlaveEntity(String json) {
        ObjectMapper objectMapper = new ObjectMapper();

        try {
           return objectMapper.readValue(
                   json,
                objectMapper.getTypeFactory().constructCollectionType(List.class, SlaveEntity.class)
            );

        } catch (IOException e) {
            e.printStackTrace();
        }
        return new ArrayList<SlaveEntity>();
    }
}

BaseEntity

public class BaseEntity {
    private long id;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }
}

SlaveEntity

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

import com.fasterxml.jackson.annotation.JsonProperty;

public class SlaveEntity extends BaseEntity {
    private String ip;

    @JsonProperty("mac")
    private String macAddress;

    private String status;

    @OneToMany(mappedBy = "slave", targetEntity = PositionEntity.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<PositionEntity> positions;

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getMacAddress() {
        return macAddress;
    }

    public void setMacAddress(String macAddress) {
        this.macAddress = macAddress;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<PositionEntity> getPositions() {
        return positions;
    }

    public void setPositions(List<PositionEntity> positions) {
        this.positions = positions;
    }

    @Override
    public String toString() {
        return String.format(
                "SlaveEntity [id=%d, ip=%s, mac=%s, status=%s, positions=%s]",
                getId(), ip, macAddress, status, positions);
    }
}

PositionEntity

public class PositionEntity {
    // ?
}

Result

SlaveEntity [id=0, ip=123, mac=456, status=null, positions=null]
SlaveEntity [id=1, ip=111, mac=222, status=null, positions=null]
🌐
Medium
medium.com › @salvipriya97 › how-to-convert-json-array-to-java-pojo-using-jackson-367ac93f7b15
How to convert JSON array to Java POJO using Jackson | by Priya Salvi | Medium
June 18, 2024 - Main Class to Convert JSON to List of Person Objects: import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; public class Main { public static void main(String[] args) { String jsonArray = "[{\"name\":\"John\", \"age\":30, \"address\":[{\"apartment\":\"A1\",\"street\":\"Main St\",\"pinCode\":\"12345\"}], \"unknownField\":\"value\"}, {\"name\":\"Alice\", \"age\":25, \"address\":[{\"apartment\":\"B2\",\"street\":\"Second St\",\"pinCode\":\"67890\"}]}]"; try { ObjectMapper objectMapper = new ObjectMapper(); List<Person> per