JSON与对象之间的转换

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.DeserializationFeature;

public class Test {
  ObjectMapper mapper = new ObjectMapper();   mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);   //JSON字符串   String jsonObj={"":""};   Student stu = mapper.readValue(jsonObj, Student.class);   //对象转JSON   JSON.toJSONString(stu);
}

 

 

 
posted @ 2019-03-21 15:43  无影-  阅读(575)  评论(0编辑  收藏  举报