Here you can find the source of writeValueAsString(Object obj)
public static String writeValueAsString(Object obj) throws JsonProcessingException
//package com.java2s; //License from project: Open Source License import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; public class Main { private static ObjectMapper objectMapper = new ObjectMapper() .setSerializationInclusion(JsonInclude.Include.NON_NULL) .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); public static String writeValueAsString(Object obj) throws JsonProcessingException { return objectMapper.writeValueAsString(obj); }/*ww w .java 2 s. c o m*/ }