from tutorial had impression should work (simplified example):
public class foo { private string bar; public string getbar() { return bar; } public void setbar(string bar) { this.bar = bar; } public static class qux { private string foobar; public string getfoobar() { return foobar; } public void setfoobar(string foobar) { this.foobar = foobar; } } } ... string in = "{ \"bar\": \"123\", \"qux\" : {\"foobar\": \"234\"}}"; objectmapper mapper = new objectmapper(); foo obj = mapper.readvalue(in, foo.class);
however, error
unrecognizedpropertyexception: unrecognized field "qux" (class foo), not marked ignorable
i'm running 2.2.2
it work if pull qux
class out of foo
public class foo { private string bar; // added private qux qux; public string getbar() { return bar; } public void setbar(string bar) { this.bar = bar; } // added getter , setter public qux getqux() { return qux; } public void setqux(qux qux) { this.qux = bar; } } public static class qux { private string foobar; public string getfoobar() { return foobar; } public void setfoobar(string foobar) { this.foobar = foobar; } }
Comments
Post a Comment