Exemple #1
0
 /** 当JSON里只含有Bean的部分属性时,更新一个已存在Bean,只覆盖该部分的属性. */
 public void update(String jsonString, Object object) {
   try {
     mapper.readerForUpdating(object).readValue(jsonString);
   } catch (JsonProcessingException e) {
     //			logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
   } catch (IOException e) {
     //			logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
   }
 }
 protected T updateEntity(T entity, String body) {
   ObjectMapper mapper = new ObjectMapper();
   try {
     return mapper.readerForUpdating(entity).readValue(body);
   } catch (Exception e) {
     log.error("", e);
     throw new ServerErrorException(e.getMessage());
   }
 }
Exemple #3
0
  /** 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性. */
  public <T> T update(String jsonString, T object) {

    try {
      return (T) mapper.readerForUpdating(object).readValue(jsonString);
    } catch (JsonProcessingException e) {
      logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
    } catch (IOException e) {
      logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
    }
    return null;
  }