Here you can find the source of object2Jason(Object obj)
public static String object2Jason(Object obj)
//package com.java2s; //License from project: Apache License import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { private static ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL); public static String object2Jason(Object obj) { try {//from ww w . ja va 2s. co m return objectMapper.writeValueAsString(obj); } catch (JsonProcessingException e) { return null; } } }