There's no built-in way to do this. You'll have to write your own JsonSerializer. Something like

class ModelSerializer extends JsonSerializer<List<Model>> {

    @Override
    public void serialize(List<Model> value, JsonGenerator jgen,
            SerializerProvider provider) throws IOException {
        jgen.writeStartArray();
        for (Model model : value) {
            jgen.writeStartObject();
            jgen.writeObjectField("model", model);
            jgen.writeEndObject();    
        }
        jgen.writeEndArray();
    }

}

and then annotate the models field so that it uses it

@JsonSerialize(using = ModelSerializer.class)
private List<Model> models;

This would serialize as

{
    "status": "success",
    "models": [
        {
            "model": {
                "id": 1,
                "color": "red"
            }
        },
        {
            "model": {
                "id": 2,
                "color": "green"
            }
        }
    ]
}

If you're both serializing and deserializing this, you'll need a custom deserializer as well.

Answer from Sotirios Delimanolis on Stack Overflow
Top answer
1 of 3
37

There's no built-in way to do this. You'll have to write your own JsonSerializer. Something like

class ModelSerializer extends JsonSerializer<List<Model>> {

    @Override
    public void serialize(List<Model> value, JsonGenerator jgen,
            SerializerProvider provider) throws IOException {
        jgen.writeStartArray();
        for (Model model : value) {
            jgen.writeStartObject();
            jgen.writeObjectField("model", model);
            jgen.writeEndObject();    
        }
        jgen.writeEndArray();
    }

}

and then annotate the models field so that it uses it

@JsonSerialize(using = ModelSerializer.class)
private List<Model> models;

This would serialize as

{
    "status": "success",
    "models": [
        {
            "model": {
                "id": 1,
                "color": "red"
            }
        },
        {
            "model": {
                "id": 2,
                "color": "green"
            }
        }
    ]
}

If you're both serializing and deserializing this, you'll need a custom deserializer as well.

2 of 3
4

This is an oldish question, But there is an arguably more idiomatic way of implementing this (I'm using jackson-databind:2.8.8):

Define a ModelSerializer (That extends StdSerializer as recommended by Jackson) that prints your model how you like and use the @JsonSerialize(contentUsing = ...) over your collection type:

class ModelSerializer extends StdSerializer<Model> {

    public ModelSerializer(){this(null);}
    public ModelSerializer(Class<Model> t){super(t);} // sets `handledType` to the provided class

    @Override
    public void serialize(List<Model> value, JsonGenerator jgen,
            SerializerProvider provider) throws IOException,
            JsonProcessingException {
        jgen.writeStartObject();
        jgen.writeObjectField("model", value);
        jgen.writeEndObject();
    }
}

Meanwhile, in another file:

class SomethingWithModels {
    // ...
    @JsonSerialize(contentUsing = ModelSerializer.class)
    private Collection<Model> models;
    // ...
}

Now you aren't bound to just Lists of models but may apply this to Collections, Sets, Native []s and even the values of Maps.

🌐
TutorialsPoint
tutorialspoint.com › how-can-we-serialize-a-list-of-objects-using-flexjson-in-java
How can we serialize a list of objects using flexjson in Java?
The Flexjson is a lightweight library for serializing and deserializing Java objects into and from JSON format. We can serialize a list of objects using the serialize() method of JSONSerializer class. This method can perform a shallow serialization of the target instance.
Discussions

java - How to serialize Object to JSON? - Stack Overflow
I need to serialize some objects to a JSON and send to a WebService. How can I do it using the org.json library? Or I'll have to use another one? Here is the class I need to serialize: public class More on stackoverflow.com
🌐 stackoverflow.com
java - How to serialize objects to json? - Stack Overflow
I have a list of objects which I want to serialize to json. More on stackoverflow.com
🌐 stackoverflow.com
September 30, 2022
How to convert List to Json in Java - Stack Overflow
I want to convert outputList into json in Java.After converting i will send it to client. ... Thats rather difficult if you just know the outputvalue is an Object. We can not even assume it is serializable. More on stackoverflow.com
🌐 stackoverflow.com
September 30, 2022
java - How to serialize object to json with Jackson, including ArrayList - Stack Overflow
I have this simple java object public class Order { static public class Product { public String name; public Integer quantity; public Float price; } public String More on stackoverflow.com
🌐 stackoverflow.com
October 10, 2024
🌐
javathinking
javathinking.com › blog › convert-list-to-json-java-objectmapper
Converting a List to JSON in Java using ObjectMapper — javathinking.com
The ObjectMapper class from the Jackson library is a powerful tool for this purpose. It provides a simple and efficient way to serialize Java objects to JSON and deserialize JSON back to Java objects.
🌐
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 - Convert List of Person objects to JSON String arrayToJson = objectMapper.writeValueAsString(personList); System.out.println("1. Convert List of person objects to JSON :"); System.out.println(arrayToJson); //2. Convert JSON to List of Person objects //Define Custom Type reference for List<Person> ...
🌐
Studytrails
studytrails.com › 2016 › 09 › 12 › java-jackson-serialization-list
Java json – jackson List serialization – Studytrails
December 9, 2025 - The example converts a Zoo class to json. the zoo class contains the name of zoo, its city and a list of animals. The list is of type ‘Animal’, i.e. the list contains elements that are subclass of the Abstract class Animal. Lets see what happens when we try to serialize zoo. First we create the Zoo class. Notice how the constructor looks. When we try to get the Zoo Object back from the JSON, Jackson has to know that it should create the Zoo Object using the constructor that takes in the name and city properties.
🌐
Oracle
blogs.oracle.com › javamagazine › java-json-serialization-jackson
Looking for a fast, efficient way to serialize and share Java objects? Try Jackson.
You certainly aren’t going to warp your application’s object model to comply with the requirements of JavaBeans merely to get serialization to work. Annotations come to the rescue again: You can modify the Person class as follows: public class Person { private final String firstName; private final String lastName; private final int age; @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) public Person(@JsonProperty("first_name") String firstName, @JsonProperty("last_name") String lastName, @JsonProperty("age") int age) { this.firstName = firstName; this.lastName = lastName; this.age = age; } @JsonProperty("first_name") public String firstName() { return firstName; } @JsonProperty("last_name") public String lastName() { return lastName; } @JsonProperty("age") public int age() { return age; } // other methods elided }
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java list › serializing and deserializing a list with gson
Serializing and Deserializing a List with Gson | Baeldung
February 19, 2026 - How do we serialize and deserialize List<Animal>? We could use TypeToken<ArrayList<Animal>> like we used in the previous section. However, Gson still won’t be able to figure out the concrete data type of the objects stored in the list. One way to solve this is to add type information to the serialized JSON.
🌐
Mosy
thepracticaldeveloper.com › java-and-json-jackson-serialization-with-objectmapper
Java and JSON – Jackson Serialization with ObjectMapper | Mosy
August 13, 2025 - The default serializer takes all the public fields and all the fields that are accessible via getters. You can alter this behavior with annotations or custom serializers. In this example, PersonName is used as a wrapper for a simple String. A list of Java objects gets serialized to a list of JSON objects containing the fields and their values.
🌐
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 com.fasterxml.jackson.d... } } } ... In Jackson library, the writeValue() method of the ObjectMapper class is used to serialize a Java object directly into a JSON file, output stream, without before converting it to a String....
🌐
javathinking
javathinking.com › blog › convert-list-of-objects-to-json-java-jersey
Convert List of Objects to JSON in Java with Jersey — javathinking.com
November 4, 2024 - JAXB is a Java technology that allows Java developers to map Java classes to XML representations. Jersey can use JAXB annotations to serialize Java objects to JSON.
🌐
MojoAuth
mojoauth.com › serialize-and-deserialize › serialize-and-deserialize-json-with-java
Serialize and Deserialize JSON with Java | Serialize & Deserialize Data Across Languages
When deserializing these structures back into Java objects, it's crucial to inform Jackson about the specific generic types involved. This ensures you get back your intended Java objects, not just generic Map or List implementations. Consider a JSON string representing a map with a list of user objects: {"users": [{"name":"Alice", "age":30}, {"name":"Bob", "age":25}]}
🌐
Baeldung
baeldung.com › home › json › jackson › intro to the jackson objectmapper
Intro to the Jackson ObjectMapper | Baeldung
December 9, 2025 - The simple readValue API of the ObjectMapper is a good entry point. We can use it to parse or deserialize JSON content into a Java object. Also, on the writing side, we can use the writeValue API to serialize any Java object as JSON output.