1. Convert the object to a JSON string, and return the value to a JSON string
public static String toJson(Object value) {try {return mapper.writeValueAsString(value);} catch (Exception e) {e.printStackTrace();} return null;} 2. Convert JSON string to entity object, return value as entity object
public static <T> T toObject(String json, Class<T> valueType) {Assert.hasText(json);Assert.notNull(valueType);try {SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");mapper.setDateFormat(dateFormat);return mapper.readValue(json, valueType);} catch (Exception e) {e.printStackTrace();}return null;