Here you can find the source of serialize(Object objData, Class
public static <T> String serialize(Object objData, Class<T> typeOfT) throws UnsupportedEncodingException, IOException
//package com.java2s; //License from project: Open Source License import com.fasterxml.jackson.databind.ObjectMapper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; public class Main { public static <T> String serialize(Object objData, Class<T> typeOfT) throws UnsupportedEncodingException, IOException { String output;//from w ww. ja v a2s. c om if (objData == null) { return null; } ObjectMapper mapper = new ObjectMapper(); ByteArrayOutputStream os = new ByteArrayOutputStream(); mapper.writeValue(os, typeOfT); output = new String(os.toByteArray(), "UTF-8"); return output; } }