@Test public void testGetMapFromObject() { SampleObject sampleObject = new SampleObject().setId(OBJ_ID).setSubObject(new SampleObject().setId(SUB_ID)); Map<String, Object> objectMap = jsonHelper.getMapFromObject(sampleObject); Assert.assertEquals(objectMap.get("id"), OBJ_ID); Map<String, Object> subObjectMap = (Map<String, Object>) objectMap.get("subObject"); Assert.assertEquals(subObjectMap.get("id"), SUB_ID); }
public Map<String, Object> getMapFromObject(Object object) { return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {}); }
JsonHelper { public Map<String, Object> getMapFromObject(Object object) { return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {}); } }
JsonHelper { public Map<String, Object> getMapFromObject(Object object) { return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {}); } JsonHelper(); }
JsonHelper { public Map<String, Object> getMapFromObject(Object object) { return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {}); } JsonHelper(); T getObjectFromRef(JsonNode rootNode, String ref, Class<T> clazz); Map<String, Object> getMapFromObject(Object object); T getObjectFromMap(Map<String, Object> map, Class<T> clazz); T getObjectFromString(String json, Class<T> clazz); String getJSONString(Object object); String getPrettyJSONString(Object object); void setNodeValue(JsonNode rootNode, String jsonPtrExpr, String value); ObjectMapper getObjectMapper(); }
JsonHelper { public Map<String, Object> getMapFromObject(Object object) { return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {}); } JsonHelper(); T getObjectFromRef(JsonNode rootNode, String ref, Class<T> clazz); Map<String, Object> getMapFromObject(Object object); T getObjectFromMap(Map<String, Object> map, Class<T> clazz); T getObjectFromString(String json, Class<T> clazz); String getJSONString(Object object); String getPrettyJSONString(Object object); void setNodeValue(JsonNode rootNode, String jsonPtrExpr, String value); ObjectMapper getObjectMapper();  }