ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Java] jackson ObjectMapper
    개발일지/Java 2024. 1. 30. 14:50

    Jackson.ObjectMapper 라이브러리

    자바 객체와 json 객체사이에서 직렬화, 역직렬화 시켜주는 라이브러리

    //객체생성
    public class Car {
    
        private String color;
        private String type;
    
        // standard getters setters
    }
    
    // 직렬화 예시
    ObjectMapper objectMapper = new ObjectMapper();
    Car car = new Car("yellow", "renault");
    objectMapper.writeValue(new File("target/car.json"), car);
    
    //역직렬화 예시
    String json = "{ \\"color\\" : \\"Black\\", \\"type\\" : \\"BMW\\" }";
    Car car = objectMapper.readValue(json, Car.class);
    

    '개발일지 > Java' 카테고리의 다른 글

    자바 Hash 알고리즘을이용해서 암호화 하기  (0) 2019.05.30

    댓글

Designed by Tistory.