사용자 도구

사이트 도구


java:jackson

차이

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

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
java:jackson [2019/02/07 20:04]
kwon37xi
java:jackson [2019/11/21 15:28]
kwon37xi
줄 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]]
줄 113: 줄 139:
   * [[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]]   * [[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]]
  
 +
 +===== JsonNodeFactory =====
 +  * [[https://fasterxml.github.io/jackson-databind/javadoc/2.1.0/com/fasterxml/jackson/databind/node/JsonNodeFactory.html|JsonNodeFactory]]
 +  * ''JsonNodeFactory.instance.objectNode()'' 를 통해 원하는 형태의 JSON 을 생성할 수 있다.
 +  * [[java:json|Java JSON]]
 +
 +<code java>
 +JsonNodeFactory.instance.objectNode().put("id", 123L)
 +            .put("name", "JSONNODE")
 +            .put("age", 12)
 +            .toString();
 +</code>
  
 ===== 참고 ===== ===== 참고 =====
java/jackson.txt · 마지막으로 수정됨: 2023/10/04 14:47 저자 kwon37xi