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.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { public static String toJson(Object object) { try {/*w w w.ja v a 2 s. co m*/ return new ObjectMapper().writeValueAsString(object); } catch (JsonProcessingException e) { return null; } } }