色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

jacksonxml使用方法

傅智翔2年前29瀏覽0評論

jacksonxml使用方法?

public class Demo1 {

public static void main(String[] args) {

XmlMapper xmlMapper = new XmlMapper();

//字段為null,自動忽略,不再序列化

xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

Department department = new Department();

Employees employees1 = new Employees("秋一葉",18,"男");

Employees employees2 = new Employees("小王",20,"男");

department.setDepName("產品研發(fā)部門");

department.setEmployees(Lists.newArrayList(employees1, employees2));

try {

//對象轉xml

String xml = xmlMapper.writeValueAsString(department);

//xml轉對象

Department dep = xmlMapper.readValue(xml, Department.class);

System.out.println("返回的xml:" + xml);

System.out.println("返回的實體:" + dep);

} catch (JsonProcessingException e) {

e.printStackTrace();

java xml對象,jacksonxml使用方法