Skip to content

Instantly share code, notes, and snippets.

@wandernauta
Created September 20, 2016 11:00
Show Gist options
  • Save wandernauta/cc3996659bac8924f55ef8fca3224c41 to your computer and use it in GitHub Desktop.
Save wandernauta/cc3996659bac8924f55ef8fca3224c41 to your computer and use it in GitHub Desktop.
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);
}
}
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