Skip to content

Instantly share code, notes, and snippets.

@moriya-hm5
Created October 23, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moriya-hm5/e3034e2bfff0a940d08811d57545eeb4 to your computer and use it in GitHub Desktop.
Save moriya-hm5/e3034e2bfff0a940d08811d57545eeb4 to your computer and use it in GitHub Desktop.
jackson
package jp.co.jackson;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
public class SampleJackson1 {
private static ObjectMapper mapper = new ObjectMapper();
@Getter
@Setter
private String id;
@Getter
@Setter
private String name;
public static void main(String[] args) throws JsonProcessingException {
SampleJackson1 jackson = new SampleJackson1();
jackson.setId("1");
jackson.setName("takahashi");
String json = mapper.writeValueAsString(jackson);
System.out.println(json);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment