Here you can find the source of toJSON(T obj)
public static <T> String toJSON(T obj)
//package com.java2s; //License from project: Artistic License public class Main { public static final com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper(); public static <T> String toJSON(T obj) { try {//from www .j a v a 2 s . c om return mapper.writeValueAsString(obj); } catch (Exception e) { throw new RuntimeException(e); } } }