Deserializes JSON string into Java object using Gson.fromJson() with Gson

Java Code Examples for

This method to deserializes a JSON string into a Java object of the specified class.



import java.util.List;
import java.util.Map;

public class GsonFromJsonExamples {

    public static void main(String... args) {
        String data = "[{\"name\":\"Sample JSON Serialization\",\"url\":\"\"},{\"name\":\"Java Tutorials\",\"url\":\"\"}]";
        Gson gson = new Gson();
        List<Map<String, String>> objectFromJsonString = gson.fromJson(data, List.class);
        System.out.println("Object from String: " + objectFromJsonString);

Happy Coding 😊