Here you can find the source of toJsonString(Object obj)
Parameter | Description |
---|---|
obj | a parameter |
public static String toJsonString(Object obj)
//package com.java2s; //License from project: Open Source License import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { /**//from w ww. j a v a 2s. c o m * Utiliza Object Mapper do Jackson para transformar objeto pojo JAVA * em string JSON. * @param obj * @return String json */ public static String toJsonString(Object obj) { ObjectMapper mapper = new ObjectMapper(); String json = null; try { json = mapper.writeValueAsString(obj); } catch (JsonProcessingException jpe) { jpe.printStackTrace(); } return json; } }