Created
October 23, 2019 21:57
-
-
Save moriya-hm5/0aaa336e9d92bad63e5952b523493bd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.co.jackson; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import lombok.Getter; | |
import lombok.Setter; | |
import lombok.ToString; | |
public class SampleJackson1 { | |
private static ObjectMapper mapper = new ObjectMapper(); | |
public static void main(String[] args) throws JsonProcessingException { | |
String json = "{\"id\":20,\"name\":\"takahashi\"}"; | |
Person person = mapper.readValue(json,Person.class); | |
System.out.println(person); | |
} | |
} | |
@Getter | |
@Setter | |
@ToString | |
class Person { | |
private String id; | |
private String name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment