Created
September 20, 2016 11:00
-
-
Save wandernauta/cc3996659bac8924f55ef8fca3224c41 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
import com.fasterxml.jackson.databind.ObjectMapper; | |
public class Example { | |
public static void main(String[] args) throws Exception { | |
String jsonInput = "{\"name\": \"Redshirt\", \"phaserToKill\": true}"; | |
new ObjectMapper().readValue(jsonInput, StarfleetEnsign.class); | |
} | |
} |
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
public class StarfleetEnsign { | |
public StarfleetEnsign() { | |
} | |
// Properties | |
private String name; | |
// Getters and setters | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
// Dangerous methods (marked as private of course) | |
private void setPhaserToKill(Object target) { | |
System.out.println("Kablooey!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment