UserDeserializer extends JsonChatDeserializer<User> { @Override public User deserialize(JsonParser jp, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jp.getCodec(); JsonNode node = oc.readTree(jp); String userId = node.get("id").asText(); String mentionName = node.get("name").asText(); boolean deleted = node.get("deleted").asBoolean(); boolean groupAdmin = getAsBooleanOrFalse(node.get("is_admin")); String statusMessage = getAsTextOrNull(node.get("status")); String timezone = getAsTextOrNull(node.get("tz")); JsonNode profileNode = node.get("profile"); String name = profileNode.get("real_name").asText(); String title = getAsTextOrNull(profileNode.get("title")); String email = getAsTextOrNull(profileNode.get("email")); String photoUrl = profileNode.get("image_32").asText(); return new User(userId, email, deleted, groupAdmin, false, name, mentionName, photoUrl, null, null, null, statusMessage, timezone, title); }  @Override User deserialize(JsonParser jp, DeserializationContext context);  }
@Test public void testDeserialize() throws Exception { User u = objMapper.readValue(userJsonStr, User.class); assertEquals("U023BECGF", u.getUserId()); assertEquals("bobby@slack.com", u.getEmail()); assertEquals("bobby", u.getMentionName()); assertEquals("Bobby Tables", u.getName()); assertEquals("https: assertEquals("America/New York/New York", u.getTimezone()); assertEquals("some status", u.getStatusMessage()); assertEquals("title", u.getTitle()); assertTrue(u.isDeleted()); assertTrue(u.isGroupAdmin()); assertNull(u.getCreationDate()); assertNull(u.getLastActiveDate()); assertNull(u.getStatus()); }