### Question:
JsonUtil { public static <T> T toObject(String json, Class<T> objectType) throws RdapClientException { return toObject(json, objectType, null); } private  JsonUtil(); static String toJson(Object object); static T toObject(String json, Class<T> objectType); static T toObject(String json, Class<T> objectType,
            Map<String, String> unknownPropertiesMap);  }### Answer:
@Test public void test_toObject() throws RdapClientException { DomainDto dto = JsonUtil.toObject(json, DomainDto.class); assertEquals("handle1", dto.getHandle()); assertEquals("dns-handle1", dto.getSecureDNS().getHandle()); assertEquals("description1", dto.getSecureDNS().getRemarks().get(0) .getDescription().get(0)); assertEquals("description2", dto.getSecureDNS().getRemarks().get(0) .getDescription().get(1)); }
@Test public void test_toObject_custom() throws RdapClientException { Map<String, String> custom = new HashMap<String, String>(); JsonUtil.toObject(jsonCustom, DomainDto.class, custom); String customString = "{\"innerCustom1\":\"1\"," + "\"innerCustom2\":[\"1\",\"2\"]}"; assertEquals(customString, custom.get("myCustom")); }
@Test public void test_toObject_updateresponse() throws RdapClientException { UpdateResponse response = JsonUtil.toObject(responseString, UpdateResponse.class); assertEquals(400, response.getErrorCode()); assertEquals(4002, response.getSubErrorCode()); assertEquals("domain-1", response.getHandle()); assertEquals("Property can't be empty: domainName", response .getDescription().get(0)); }
@Test public void test_toObject_exception() { UpdateResponse response; String message = null; try { response = JsonUtil.toObject(responseException, UpdateResponse.class); } catch (RdapClientException e) { response = null; message = e.getMessage(); } assertEquals(null, response); String[] messages = message.split("\n"); assertEquals(ExceptionMessage.JSON_TO_OBJECT_ERROR.getMessage(), messages[0] + "\n"); }