* 출처:http://stackoverflow.com/questions/4486787/jackson-with-json-unrecognized-field-not-marked-as-ignorable
import org.codehaus.jackson.map.ObjectMapper;
public class TestObjectmapper implements SubJobRunner {
public static void main(String[] args) {
// String jsonStr = "{\"wrapper\"\:[{\"id\":\"13\",\"name\":\"Fred\"}]}";
String jsonStr = "{}";
ObjectMapper mapper = new ObjectMapper();
Wrapper wrapper = null;
try {
wrapper = mapper.readValue(jsonStr , Wrapper.class);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("111111111111111");
System.out.println("wrapper = " + wrapper);
System.out.println("222222222222222222");
}
public class Student {
private String name;
private String id;
//getters & setters for name & id here
}
public class Wrapper {
private List<Student> students;
//getters & setters here
}
}