Java後台JOSN轉換為Stirng
jackson-mapper-asl-1.6.4.jar
import org.codehaus.jackson.map.ObjectMapper;
public static String convertObjectToJsonString(Object data){
return convertObjectToJsonString(null,data);
}
public static String convertObjectToJsonString(ObjectMapper mapper,Object data){
String json = "";
if(data==null) return json;
try {
if(mapper==null) mapper = new ObjectMapper();
json = mapper.writeValueAsString(data);
} catch (Exception e) {
log.error("convertObjectToJsonString", e);
}
return json;
}