Memory Drive

반응형


import com.fasterxml.jackson.core.JsonGenerationException;

import com.fasterxml.jackson.databind.JsonMappingException;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.databind.SerializationFeature;


...

....

....


public static String getJSON(Map<?, ?> map) throws JsonGenerationException, JsonMappingException, IOException

{

if (map == null ) return null;

ObjectMapper mapper = new ObjectMapper();


// pretty format

mapper.configure(SerializationFeature.INDENT_OUTPUT, true);

StringWriter sw = new StringWriter();

mapper.writeValue(sw, map);

return sw.toString();

}


반응형

'Computer_IT > JAVA' 카테고리의 다른 글

JDK 7 release - Bug Fixes history  (0) 2014.10.20
eclipse @author 변경하기  (0) 2013.07.02
VisualSVN Post-commit hook  (0) 2013.02.04
마이피플 위젯 전송 자바 샘플  (0) 2012.07.11
myBatis multi db vendor support  (0) 2011.12.07