Serializes Java object into JSON string using JsonStream.serialize() with Jsoniter

Tags: JSON jsoniter

Java Code Examples for com.jsoniter.output.JsonStream.serialize()

This method to serializes the Java object into JSON string.

Adding Jsoniter dependency into your project

Using Gradle

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

Using Maven


How to use com.jsoniter.output.JsonStream.serialize()


import com.jsoniter.output.JsonStream;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JsonStreamSerializeExamples {

    public static void main(String... args) {
        List<Map<String, String>> data = new ArrayList<>();
        Map<String, String> item1 = new HashMap<>();
        item1.put("name", "Sample JSON Serialization");
        item1.put("url", "");

        Map<String, String> item2 = new HashMap<>();
        item2.put("name", "Java Tutorials");
        item2.put("url", "");

        String jsonStringFromObject = JsonStream.serialize(data);
        System.out.println("JSON String from Object: " + jsonStringFromObject);

Happy Coding 😊