JsonUtil.java 606 Bytes
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
package com.lyms.talkonlineweb.util;

import com.fasterxml.jackson.databind.ObjectMapper;


/**
* Created by Administrator on 2019-09-06.
*/
public class JsonUtil {



/**
* 对象转换为String
* @param cls
* @return
*/
public static String obj2Str(
Object cls) {
try {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(DateUtil.getDateFormat(DateUtil.YYYY_MM_DD_HH_MM_SS));
return objectMapper.writeValueAsString(cls);
} catch (Exception e) {

}
return null;
}

}