I’ve written the following:
ObjectMapper oMapper = new ObjectMapper();
Object oPOJO = null;
String p_strJSON = "{\"name\" : { \"first\" : \"Joe\", \"last\" : "
+ "\"Sixpack\" },\"gender\" : \"MALE\",\"verified\" : \"false\","
+ "\"userImage\" : \"Rm9vYmFyIQ==\"}";
try
{
oPOJO = oMapper.readValue(p_strJSON, User.class);
}
catch(Throwable oThrowable)
{
System.out.println(oThrowable.getMessage());
throw new RuntimeException(oThrowable);
}
And am getting the following exception message when it executes:
Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: java.io.StringReader@3eca90; line: 1, column: 1]
Am I using Jackson incorrectly? I’m using the 1.9.6 JAR – do I need to set anything up in the claspath maybe?
Given your user class looks something like this, your code passes