List of utility methods to do Object to Json
String | toJsonString(Object obj) Utiliza Object Mapper do Jackson para transformar objeto pojo JAVA em string JSON. ObjectMapper mapper = new ObjectMapper(); String json = null; try { json = mapper.writeValueAsString(obj); } catch (JsonProcessingException jpe) { jpe.printStackTrace(); return json; ... |
String | toJSONString(Object object, boolean camelCaseToLowerCaseWithUnderscores) to JSON String ObjectMapper mapper = camelCaseToLowerCaseWithUnderscores ? LCWU_OBJECT_MAPPER : OBJECT_MAPPER;
return mapper.writeValueAsString(object);
|
String | toJsonString(T value) to Json String try { return mapper.writeValueAsString(value); } catch (JsonProcessingException e) { throw new IllegalArgumentException(String.format( "Illegal argument. Could not convert object %s to JSON string: (%s)", value, e.getMessage())); |
String | writeJSON(HashMap write JSON if (data == null) return null; String json = null; try { json = mapper.writeValueAsString(data); } catch (JsonProcessingException e) { e.printStackTrace(); if (json == null) json = "{}"; return json; |
byte[] | writeValueAsBytes(Object value) write Value As Bytes try { return OBJECT_MAPPER.writeValueAsBytes(value); } catch (JsonProcessingException e) { throw new IllegalStateException(e); |
String | writeValueAsIndentString(Object value) write Value As Indent String return indentMapper.writeValueAsString(value);
|
String | writeValueAsString(Object o) write Value As String String t = mapper.writeValueAsString(o);
return t;
|
String | writeValueAsString(Object obj) write Value As String return objectMapper.writeValueAsString(obj);
|
String | writeValueAsString(Object obj) write Value As String try { return OBJECT_MAPPER.writeValueAsString(obj); } catch (Exception e) { System.err.println(e.getMessage()); return null; |