/** * Encode a POJO to JSON using the underlying Jackson mapper. * * @param obj a POJO * @return a String containing the JSON representation of the given POJO. * @throws EncodeException if a property cannot be encoded. */ public static String encode(Object obj) throws EncodeException { try { return mapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON: " + e.getMessage()); } }
/** * Encode a POJO to JSON with pretty indentation, using the underlying Jackson mapper. * * @param obj a POJO * @return a String containing the JSON representation of the given POJO. * @throws EncodeException if a property cannot be encoded. */ public static String encodePrettily(Object obj) throws EncodeException { try { return prettyMapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON: " + e.getMessage()); } }
/** * Encode a POJO to JSON using the underlying Jackson mapper. * * @param obj a POJO * @return a Buffer containing the JSON representation of the given POJO. * @throws EncodeException if a property cannot be encoded. */ public static Buffer encodeToBuffer(Object obj) throws EncodeException { try { return Buffer.buffer(mapper.writeValueAsBytes(obj)); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON: " + e.getMessage()); } }
public static String encode(Object obj) throws EncodeException { try { return mapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON"); } }
/** * Encode a POJO to JSON using the underlying Jackson mapper. * * @param obj a POJO * @return a String containing the JSON representation of the given POJO. * @throws EncodeException if a property cannot be encoded. */ public static String encode(Object obj) throws EncodeException { try { return mapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON: " + e.getMessage()); } }
/** * Encode a POJO to JSON with pretty indentation, using the underlying Jackson mapper. * * @param obj a POJO * @return a String containing the JSON representation of the given POJO. * @throws EncodeException if a property cannot be encoded. */ public static String encodePrettily(Object obj) throws EncodeException { try { return prettyMapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON: " + e.getMessage()); } }
/** * Encode a POJO to JSON using the underlying Jackson mapper. * * @param obj a POJO * @return a Buffer containing the JSON representation of the given POJO. * @throws EncodeException if a property cannot be encoded. */ public static Buffer encodeToBuffer(Object obj) throws EncodeException { try { return Buffer.buffer(mapper.writeValueAsBytes(obj)); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON: " + e.getMessage()); } }
public static String encode(Object obj) throws EncodeException { try { return mapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON"); } }
public static String encode(Object obj) throws EncodeException { try { return mapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON"); } }
public static String encode(Object obj) throws EncodeException { try { return mapper.writeValueAsString(obj); } catch (Exception e) { throw new EncodeException("Failed to encode as JSON"); } }
public static String encode(Object item) { try { return MAPPER.writeValueAsString(item); } catch (JsonProcessingException e) { throw new EncodeException(e.getMessage()); } }
public static String encodePretty(Object item) { try { return PRETTY_MAPPER.writeValueAsString(item); } catch (JsonProcessingException e) { throw new EncodeException(e.getMessage()); } }
public static void appendCString(Buffer buffer, String value) { byte[] bytes = value.getBytes(UTF8); // validate if it is a real C string for (byte aByte : bytes) { if (aByte == '\0') { throw new EncodeException("Key: '" + value + "' is not a CString"); } } buffer.appendBytes(bytes); buffer.appendByte((byte) 0x00); }
LE.appendCString(buffer, key); } else { throw new EncodeException("Don't know how to encodeObject: " + value); throw new EncodeException("Don't know how to encode: " + value.getClass().getName());