Computer_IT/JAVA
jackson parser sample
고급코드
2013. 4. 2. 13:54
반응형
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();
}
반응형