The JSON is invalid. A collection is not to be represented by {}. It stands for an object. A collection/array is to be represented by [] with commaseparated objects.

Here's how the JSON should look like:

{
    users:[{
        name: "name1",
        email: "email1",
        friends:[{
            name: "name2",
            email: "email2",
            friends:[{
                name: "name3",
                email: "email3"
            },
            {
                name: "name4",
                email: "email4"
            }]
        }]
    }]
}

(note that I added one more friend to the deepest nested friend, so that you understand how to specify multiple objects in a collection)

Given this JSON, your wrapper class should look like this:

public class Data {
    private List<User> users;
    // +getters/setters
}

public class User {
    private String name;
    private String email;
    private List<User> friends;
    // +getters/setters
}

and then to convert it, use

Data data = gson.fromJson(this.json, Data.class);

and to get the users, use

List<User> users = data.getUsers();
Answer from BalusC on Stack Overflow
🌐
Javadoc.io
javadoc.io › doc › com.google.code.gson › gson › 2.8.5 › com › google › gson › Gson.html
Gson - gson 2.8.5 javadoc
Bookmarks · Latest version of com.google.code.gson:gson · https://javadoc.io/doc/com.google.code.gson/gson · Current version 2.8.5 · https://javadoc.io/doc/com.google.code.gson/gson/2.8.5 · package-list path (used for javadoc generation -link option) · https://javadoc.io/doc/com.goog...
🌐
GitHub
google.github.io › gson › UserGuide.html
Gson User Guide | gson
Gson gson = new Gson(); int[] ints = {1, 2, 3, 4, 5}; String[] strings = {"abc", "def", "ghi"}; // Serialization gson.toJson(ints); // ==> [1,2,3,4,5] gson.toJson(strings); // ==> ["abc", "def", "ghi"] // Deserialization int[] ints2 = gson.fromJson("[1,2,3,4,5]", int[].class); // ==> ints2 will be same as ints
🌐
Stack Overflow
stackoverflow.com › questions › 55971802 › how-does-gson-fromjsonstring-class-work
java - How does Gson.fromJson(String, Class) work? - Stack Overflow
I doubt this json + pojo work together. Just checked: If you add a toString to Info the output will be "Info{name=null, father=null, mother=null}" which is as expected because Gson (as expected) cannot map anything here.
🌐
Medium
medium.com › @alexandre.therrien3 › personalized-serializer-and-deserializer-using-java-gson-library-c079de3974d4
Building a Personalized Serializer and Deserializer using Java Gson Library | by Alex Therrien | Medium
June 2, 2020 - There are only some rare cases where this needs to be done. I did it because I created my own linked list and wanted to convert it into JSON. By default, Gson can automatically convert objects to their corresponding JSON format.
🌐
TutorialsPoint
tutorialspoint.com › differences-between-fromjson-and-tojson-methods-of-gson-in-java
Differences between fromJson() and toJson() methods of Gson in Java?
May 13, 2025 - Here is the syntax of the fromJson() method: gson.fromJson(json, Person.class); The toJson() method is used to convert a Java object into a JSON string. It takes one parameter: the Java object you want to convert.
Find elsewhere
🌐
Javadoc.io
javadoc.io › doc › com.google.code.gson › gson › latest › com.google.gson › com › google › gson › Gson.html
Gson - gson 2.13.2 javadoc
Bookmarks · Latest version of com.google.code.gson:gson · https://javadoc.io/doc/com.google.code.gson/gson · Current version 2.13.2 · https://javadoc.io/doc/com.google.code.gson/gson/2.13.2 · package-list path (used for javadoc generation -link option) · https://javadoc.io/doc/com.go...
🌐
GitHub
github.com › google › gson
GitHub - google/gson: A Java serialization/deserialization library to convert Java Objects into JSON and back · GitHub
The Moshi APIs may be more familiar to users who already know Gson. If you still want to use Gson and attempt to avoid these crashes, you can see how to do so here. Provide simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa ·
Starred by 24.3K users
Forked by 4.4K users
Languages   Java
🌐
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 - @Test public void givenJsonString_whenDeserializing_thenReturnListOfMyClass() { String inputString = "[{\"id\":1,\"name\":\"name1\"},{\"id\":2,\"name\":\"name2\"}]"; List<MyClass> inputList = Arrays.asList(new MyClass(1, "name1"), new MyClass(2, "name2")); Type listOfMyClassObject = new TypeToken<ArrayList<MyClass>>() {}.getType(); Gson gson = new Gson(); List<MyClass> outputList = gson.fromJson(inputString, listOfMyClassObject); assertEquals(inputList, outputList); } Here, we use Gson’s TypeToken to determine the correct type to be deserialized – ArrayList<MyClass>. The idiom used to get the listOfMyClassObject actually defines an anonymous local inner class containing a method getType() that returns the fully parameterized type.
🌐
HowToDoInJava
howtodoinjava.com › home › gson › gson tutorial: read and write json with examples
Gson Tutorial: Read and Write JSON with Examples
August 27, 2023 - Gson gson = new Gson(); User user = new User(); String json = gson.toJson(user); Similarly, to convert the JSON string to a Java object, use the fromJson() method.
🌐
Attacomsian
attacomsian.com › blog › gson-read-json-file
How to read JSON from a file using Gson in Java
October 14, 2022 - The following example shows how you can read the above JSON file into a User object by using the fromJson() method: try { // create Gson instance Gson gson = new Gson(); // create a reader Reader reader = Files.newBufferedReader(Paths.get("user.json")); // convert a JSON string to a User object User user = gson.fromJson(reader,User.class); // print user object System.out.println(user); // close reader reader.close(); } catch (Exception ex) { ex.printStackTrace(); } You should see the following output printed on the console: User{name='John Doe', email='john.doe@example.com', roles=[Member, Adm
🌐
Baeldung
baeldung.com › home › json › convert string to jsonobject with gson
Convert String to JsonObject with Gson | Baeldung
May 5, 2025 - In this tutorial, we’ll learn how Gson can give us a JsonObject from a String.
🌐
Adobe Developer
developer.adobe.com › experience-manager › reference-materials › 6-5 › javadoc › com › google › gson › Gson.html
Gson (The Adobe AEM Quickstart and Web Application.)
This method deserializes the specified Json into an object of the specified type. This method is useful if the specified object is a generic type. For non-generic objects, use fromJson(String, Class) instead.
🌐
IronPDF
ironpdf.com › ironpdf for java › ironpdf for java blog › java help › gson java
Gson Java (How It Works For Developers)
June 23, 2025 - In this example, we create a Gson object and use it to serialize a MyObject instance into a JSON string (toJson method). We then deserialize the JSON string and convert it back into a MyObject instance (fromJson method).
🌐
GeeksforGeeks
geeksforgeeks.org › java › convert-java-object-to-json-string-using-gson
Convert Java Object to Json String using GSON - GeeksforGeeks
July 11, 2025 - GSON: It is an open-source Java library which is used to serialize and deserialize Java objects to JSON.
🌐
Maven Repository
mvnrepository.com › artifact › com.google.code.gson › gson
Maven Repository: com.google.code.gson » gson
September 10, 2025 - Gson is a Java library that can be used to convert Java Objects into their JSON representation.
🌐
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 - String userJson = "[{'name': 'Alex','id': 1}, " + "{'name': 'Brian','id':2}, " + "{'name': 'Charles','id': 3}]"; Gson gson = new Gson(); User[] userArray = gson.fromJson(userJson, User[].class); for(User user : userArray) { System.out.println(user); }
🌐
TutorialsPoint
tutorialspoint.com › gson › gson_quick_guide.htm
GSON - Quick Guide
GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create(); Use fromJson() method to get the Object from the JSON. Pass Json string / source of Json string and object type as parameter.