Parse simple JSON with Jackson
- by siik
Here is my JSON:
{
"i": 53691,
"s": "Something" }
Here is my model:
public class Test() {
private int i;
private String s;
public setInt(int i){ this.i = i; }
public setString(String s){ this.s = s; }
// getters here
}
Here is my class for server's response:
public class ServerResponse(){
private Test;
public void setTest(Test test){ this.test = test;}
public Test getTest(){ return Test; } }
When I do:
ObjectMapper mapper = new ObjectMapper();
mapper.readValue(json, serverResponse);
I'm getting an exception like:
JsonProcessingException: Unrecognized field "i" (Class MyClass), not
marked as ignorable
Please advice.