Here you can find the source of toJson(Object object)
public static String toJson(Object object)
//package com.java2s; //License from project: Apache License import com.fasterxml.jackson.databind.ObjectMapper; public class Main { private static ObjectMapper objectMapper = new ObjectMapper(); public static String toJson(Object object) { try {// ww w . ja v a2 s . c om if (object == null) { return null; } return objectMapper.writeValueAsString(object); } catch (Exception e) { return null; } } }