사용자 도구

사이트 도구


java:jackson

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
java:jackson [2019/02/07 19:57]
kwon37xi
java:jackson [2019/02/28 15:46]
kwon37xi [@JsonCreator]
줄 23: 줄 23:
   * 해당 클래스 JSON 문자열을 받아서 객체를 생성할 때 변환기를 직접 만들고자 할 때 구현한다.   * 해당 클래스 JSON 문자열을 받아서 객체를 생성할 때 변환기를 직접 만들고자 할 때 구현한다.
   * [[https://fasterxml.github.io/jackson-annotations/javadoc/2.7/com/fasterxml/jackson/annotation/JsonCreator.html|@JsonCreator]]   * [[https://fasterxml.github.io/jackson-annotations/javadoc/2.7/com/fasterxml/jackson/annotation/JsonCreator.html|@JsonCreator]]
 +  * [[https://grokonez.com/java/jackson-jsoncreator-example-deserialize-jsoncreator|Jackson @JsonCreator example - Deserialize with @JsonCreator - grokonez]] 
 +<code java> 
 +public class Customer { 
 +    private String id; 
 +    private String name; 
 +    private String address; 
 +  
 +    public Customer() { 
 +    } 
 +  
 +    @JsonCreator 
 +    public Customer( 
 +            @JsonProperty("id") String id,  
 +            @JsonProperty("fullname") String name, 
 +            @JsonProperty("location") String address) { 
 +        System.out.println("run constructor..."); 
 +        this.id = id; 
 +        this.name = name; 
 +        this.address = address; 
 +    } 
 +  
 +    @Override 
 +    public String toString() { 
 +        return "Customer [id=" + id + ", name=" + name + ", address=" + address + "]"; 
 +    } 
 +
 +</code>
 ===== Performance ===== ===== Performance =====
   * [[http://wiki.fasterxml.com/JacksonBestPracticesPerformance|Jackson Best Practice Performance]]   * [[http://wiki.fasterxml.com/JacksonBestPracticesPerformance|Jackson Best Practice Performance]]
줄 110: 줄 136:
   * [[https://www.logicbig.com/tutorials/misc/jackson/json-raw-value.html|Jackson JSON - Using @JsonRawValue to serialize property as it is]]   * [[https://www.logicbig.com/tutorials/misc/jackson/json-raw-value.html|Jackson JSON - Using @JsonRawValue to serialize property as it is]]
   * String 필드게 JSON 문자열이 저장돼 있을 경우 이를 JSON 으로 간주하고 리턴   * String 필드게 JSON 문자열이 저장돼 있을 경우 이를 JSON 으로 간주하고 리턴
 +  * 직렬화에서는 작동하지만 역직렬화에서는 작동하지 않는다.
 +  * [[https://stackoverflow.com/questions/4783421/how-can-i-include-raw-json-in-an-object-using-jackson|java - How can I include raw JSON in an object using Jackson? - Stack Overflow]]
  
  
줄 125: 줄 153:
   * [[https://www.baeldung.com/jackson-serialize-enums|How To Serialize Enums as JSON Objects with Jackson | Baeldung]]   * [[https://www.baeldung.com/jackson-serialize-enums|How To Serialize Enums as JSON Objects with Jackson | Baeldung]]
   * [[https://www.baeldung.com/jackson-mapping-dynamic-object|Mapping a Dynamic JSON Object with Jackson | Baeldung]]   * [[https://www.baeldung.com/jackson-mapping-dynamic-object|Mapping a Dynamic JSON Object with Jackson | Baeldung]]
 +  * [[https://www.baeldung.com/jackson-annotations|Jackson Annotation Examples | Baeldung]]
   * [[https://cheese10yun.github.io/jackson-annotation/|Jackson 어노테이션 사용법(1) - Yun Blog]]   * [[https://cheese10yun.github.io/jackson-annotation/|Jackson 어노테이션 사용법(1) - Yun Blog]]
java/jackson.txt · 마지막으로 수정됨: 2023/10/04 14:47 저자 kwon37xi