Java JAXB Marshalling / UnMarshalling 1. Marshalling (POJO to xml) Value Object Class @Setter @XmlRootElement public class TestValue { @XmlElement public String name; @XmlElement public int age; } Marshalling TestValue testValue = new TestValue(); testValue.setAge(30); testValue.setName("name"); JAXBContext context = JAXBContext.newInstance(TestValue.class); Marshaller marshaller = context.creat..
Java Gson pom.xml 에 dependency 추가 pom.xml 내용 com.google.code.gson gson 1. Java object to json Value Object Class @Data public class TestValue { public String name; public int age; } Gson 을 이용해 Object to Json string convert ObjectMapper objectMapper = new ObjectMapper(); TestValue testValue = new TestValue(); testValue.setAge(30); testValue.setName("name"); Gson gson = new Gson(); // Java Object ..
Java Jackson ObjectMapper 1. pom.xml 에 dependency 추가 xml 내용 com.fasterxml.jackson.core jackson-databind ${jackson.version} 2. Java object to json Serialize Value Object Class @Data public class TestValue { public String name; public int age; } ObjectMapper를 이용해 Object to Json ObjectMapper objectMapper = new ObjectMapper(); TestValue testValue = new TestValue(); testValue.setAge(30); testValue.se..