Here you can find the source of toJson(Object o)
public static String toJson(Object o)
//package com.java2s; //License from project: Apache License import java.util.TimeZone; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { public static String toJson(Object o) { try {/* w w w. j av a 2s.c o m*/ return getObjectMapper().writeValueAsString(o); } catch (Exception e) { e.printStackTrace(); return "<exception>"; } } public static ObjectMapper getObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); return mapper; } }