Deserializes JSON String into Java object using JSON.parseObject() with Fastjson

Tags: JSON fastjson

Java Code Examples for com.alibaba.fastjson.JSON.parseObject()

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

Adding Fastjson dependency into your project

Using Gradle

compile group: 'com.alibaba', name: 'fastjson', version: '1.2.56'

Using Maven

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.56</version>
</dependency>

How to use com.alibaba.fastjson.JSON.parseObject()

package simplesolution.dev;

import com.alibaba.fastjson.JSON;

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

public class JSONParseObjectExamples {

    public static void main(String... args) {
        String data = "[{\"name\":\"Sample JSON Serialization\",\"url\":\"https://simplesolution.dev\"},{\"name\":\"Java Tutorials\",\"url\":\"https://simplesolution.dev/java\"}]";
        List<Map<String, String>> objectFromJsonString = JSON.parseObject(data, List.class);
        System.out.println("Object from String: " + objectFromJsonString);

    }
}

Happy Coding 😊