Deserializes JSON string into Java object using JsonIterator.deserialize() with Jsoniter

Tags: JSON jsoniter

Java Code Examples for com.jsoniter.JsonIterator.deserialize()

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

Adding Jsoniter dependency into your project

Using Gradle

compile group: 'com.jsoniter', name: 'jsoniter', version: '0.9.23'

Using Maven

<dependency>
    <groupId>com.jsoniter</groupId>
    <artifactId>jsoniter</artifactId>
    <version>0.9.23</version>
</dependency>

How to use com.jsoniter.JsonIterator.deserialize()

package simplesolution.dev;

import com.jsoniter.JsonIterator;

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

public class JsonIteratorDeserializeExamples {

    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 = JsonIterator.deserialize(data, List.class);
        System.out.println("[Jsoniter] Object from String: " + objectFromJsonString);
    }
}

Happy Coding 😊