fastjson使用
fastjson pase 出来的对象一定要判Null
原因: fastjson 可以把"null" 解析成空对象, 所以必须判Null, 否则可能出现空指针异常
示例代码:
public static void main(String[] args) {
String str = "null";
Object source = JSON.parseObject(str, Object.class);
Object target = new Object();
BeanUtils.copyProperties(source, target);
}
Exception in thread "main" java.lang.IllegalArgumentException: Source must not be null
at org.springframework.util.Assert.notNull(Assert.java:198)
at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:693)
at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:639)

浙公网安备 33010602011771号