/** * Decode a given JSON string to a POJO of the given type. * @param str the JSON string. * @param type the type to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(String str, TypeReference<T> type) throws DecodeException { try { return mapper.readValue(str, type); } catch (Exception e) { throw new DecodeException("Failed to decode: " + e.getMessage(), e); } }
/** * Decode a given JSON string to a POJO of the given class type. * @param str the JSON string. * @param clazz the class to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(String str, Class<T> clazz) throws DecodeException { try { return mapper.readValue(str, clazz); } catch (Exception e) { throw new DecodeException("Failed to decode: " + e.getMessage()); } }
<T> T convert(Class<T> type) { try { return Json.mapper.readValue(buffer.asParser(), type); } catch (Exception e) { throw new DecodeException(e.getMessage()); } } }
@Override public <T> T mapTo(Class<T> type) { if (buffer != null) { try { return Json.mapper.readValue(buffer.asParser(), type); } catch (Exception e) { throw new DecodeException(e.getMessage()); } } else { return Json.decodeValue(String.valueOf(value), type); } }
@Override public <T> T mapTo(TypeReference<T> type) { if (buffer != null) { try { return Json.mapper.readValue(buffer.asParser(), type); } catch (Exception e) { throw new DecodeException(e.getMessage()); } } else { return Json.decodeValue(String.valueOf(value), type); } }
/** * Decode a given JSON buffer to a POJO of the given class type. * @param buf the JSON buffer. * @param clazz the class to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(Buffer buf, Class<T> clazz) throws DecodeException { try { return mapper.readValue((InputStream) new ByteBufInputStream(buf.getByteBuf()), clazz); } catch (Exception e) { throw new DecodeException("Failed to decode:" + e.getMessage(), e); } }
/** * Decode a given JSON buffer to a POJO of the given class type. * @param buf the JSON buffer. * @param type the type to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(Buffer buf, TypeReference<T> type) throws DecodeException { try { return mapper.readValue(new ByteBufInputStream(buf.getByteBuf()), type); } catch (Exception e) { throw new DecodeException("Failed to decode:" + e.getMessage(), e); } }
@Override public void handle(Buffer event) { byte[] bytes = event.getBytes(); try { parser.feedInput(bytes, 0, bytes.length); } catch (IOException e) { if (exceptionHandler != null) { exceptionHandler.handle(e); return; } else { throw new DecodeException(e.getMessage()); } } checkPending(); }
exceptionHandler.handle(e); } else { throw new DecodeException(e.getMessage());
public static <T> T decodeValue(String str, Class<T> clazz) throws DecodeException { try { return mapper.readValue(str, clazz); } catch (Exception e) { throw new DecodeException("Failed to decode"); } } }
/** * Decode a given JSON string to a POJO of the given class type. * @param str the JSON string. * @param clazz the class to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(String str, Class<T> clazz) throws DecodeException { try { return mapper.readValue(str, clazz); } catch (Exception e) { throw new DecodeException("Failed to decode: " + e.getMessage()); } }
/** * Decode a given JSON string to a POJO of the given type. * @param str the JSON string. * @param type the type to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(String str, TypeReference<T> type) throws DecodeException { try { return mapper.readValue(str, type); } catch (Exception e) { throw new DecodeException("Failed to decode: " + e.getMessage(), e); } }
throw new DecodeException(e.getMessage());
<T> T convert(Class<T> type) { try { return Json.mapper.readValue(buffer.asParser(), type); } catch (Exception e) { throw new DecodeException(e.getMessage()); } } }
@Override public <T> T mapTo(Class<T> type) { if (buffer != null) { try { return Json.mapper.readValue(buffer.asParser(), type); } catch (Exception e) { throw new DecodeException(e.getMessage()); } } else { return Json.decodeValue(String.valueOf(value), type); } }
@Override public <T> T mapTo(TypeReference<T> type) { if (buffer != null) { try { return Json.mapper.readValue(buffer.asParser(), type); } catch (Exception e) { throw new DecodeException(e.getMessage()); } } else { return Json.decodeValue(String.valueOf(value), type); } }
/** * Decode a given JSON buffer to a POJO of the given class type. * @param buf the JSON buffer. * @param type the type to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(Buffer buf, TypeReference<T> type) throws DecodeException { try { return mapper.readValue(new ByteBufInputStream(buf.getByteBuf()), type); } catch (Exception e) { throw new DecodeException("Failed to decode:" + e.getMessage(), e); } }
/** * Decode a given JSON buffer to a POJO of the given class type. * @param buf the JSON buffer. * @param clazz the class to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(Buffer buf, Class<T> clazz) throws DecodeException { try { return mapper.readValue((InputStream) new ByteBufInputStream(buf.getByteBuf()), clazz); } catch (Exception e) { throw new DecodeException("Failed to decode:" + e.getMessage(), e); } }
@Override public void handle(Buffer event) { byte[] bytes = event.getBytes(); try { parser.feedInput(bytes, 0, bytes.length); } catch (IOException e) { if (exceptionHandler != null) { exceptionHandler.handle(e); return; } else { throw new DecodeException(e.getMessage()); } } checkPending(); }
exceptionHandler.handle(e); } else { throw new DecodeException(e.getMessage());