import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JSON {
private static final ObjectMapper mapper=new ObjectMapper();
public static <V extends Object> V parse(String str, Class<V> type) {
V value = null;
if (str != null) {
try {
value = mapper.readValue(str, type);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
return value;
}
public static String stringify(Object type) {
String json = null;
try {
json = mapper.writeValueAsString(type);
} catch (Exception e) {
e.printStackTrace();
}
return json;
}
}