Created
May 22, 2017 21:39
-
-
Save coopernurse/639e91b34b51bee736e29d12812ecf24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import com.fasterxml.jackson.databind.ObjectMapper; | |
public class MyData { | |
public static void main(String argv[]) throws Exception { | |
String json = "{\"name\": \"foo\", \"age\": 30 }"; | |
MyData d = new ObjectMapper().readValue(json, MyData.class); | |
System.out.println(" json: " + json); | |
System.out.println("deserialized: " + d); | |
} | |
private String name; | |
private int age; | |
public String getName() { | |
return name; | |
} | |
public int getAge() { | |
return age; | |
} | |
@Override | |
public String toString() { | |
return "MyData{" + | |
"name='" + name + '\'' + | |
", age=" + age + | |
'}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this prints: