jackson mapping fix
This commit is contained in:
parent
528ef210e4
commit
06b521b4ee
|
@ -22,7 +22,7 @@ public class ItemDeserializer extends JsonDeserializer<Item> {
|
|||
final JsonNode node = jp.getCodec().readTree(jp);
|
||||
final int id = (Integer) ((IntNode) node.get("id")).numberValue();
|
||||
final String itemName = node.get("itemName").asText();
|
||||
final int userId = (Integer) ((IntNode) node.get("owner")).numberValue();
|
||||
final int userId = (Integer) ((IntNode) node.get("createdBy")).numberValue();
|
||||
|
||||
return new Item(id, itemName, new User(userId, null));
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public class JacksonDeserializationUnitTest {
|
|||
|
||||
@Test
|
||||
public final void whenDeserializingANonStandardRepresentation_thenCorrect() throws JsonParseException, JsonMappingException, IOException {
|
||||
final String json = "{\"id\":1,\"itemName\":\"theItem\",\"owner\":2}";
|
||||
final String json = "{\"id\":1,\"itemName\":\"theItem\",\"createdBy\":2}";
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
final SimpleModule module = new SimpleModule();
|
||||
|
|
Loading…
Reference in New Issue