public static <T> T fromJson(String jsonStr, Class<T> valueType) throws ParseJsonException { try { return mapper.readValue(jsonStr, valueType); } catch (Exception e) { throw new ParseJsonException("Failed to deserialize Object from Json string"); } }
LOG.error("Meet Exception: ", e); response.setCode(HttpServer.StatusCode.NOT_FOUND); response.setBody("ERROR parameters: " + e.getMessage()); return response;
public static String toJson(Object object) throws ParseJsonException { try { return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object); } catch (Exception e) { throw new ParseJsonException("Failed to serialize Object to Json string"); } }