Here you can find the source of toJsonString(T value)
public static <T> String toJsonString(T value)
//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 final ObjectMapper mapper = new ObjectMapper(); public static <T> String toJsonString(T value) { try {// ww w . j a v a2s. c o m return mapper.writeValueAsString(value); } catch (JsonProcessingException e) { throw new IllegalArgumentException(String.format( "Illegal argument. Could not convert object %s to JSON string: (%s)", value, e.getMessage())); } } }