Parse simple JSON with Jackson
Posted
by
siik
on Stack Overflow
See other posts from Stack Overflow
or by siik
Published on 2012-11-27T16:18:01Z
Indexed on
2012/11/27
17:04 UTC
Read the original article
Hit count: 365
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.
© Stack Overflow or respective owner