/** * Creates a new empty ObjectNode. * @return new empty ObjectNode. */ public static ObjectNode newObject() { return mapper().createObjectNode(); }
/** * Creates a new empty ObjectNode. * @return new empty ObjectNode. */ public static ObjectNode newObject() { return mapper().createObjectNode(); }
/** * Creates a new empty ObjectNode. * @return new empty ObjectNode. */ public static ObjectNode newObject() { return mapper().createObjectNode(); }
/** * Parses a byte array representing a json, and return it as a JsonNode. * @param src the JSON input bytes. * @return the JSON node. */ public static JsonNode parse(byte[] src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Parses a InputStream representing a json, and return it as a JsonNode. * @param src the JSON input stream. * @return the JSON node. */ public static JsonNode parse(java.io.InputStream src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Converts an object to JsonNode. * * @param data Value to convert in Json. * @return the JSON node. */ public static JsonNode toJson(final Object data) { try { return mapper().valueToTree(data); } catch(Exception e) { throw new RuntimeException(e); } }
/** * Parses a byte array representing a json, and return it as a JsonNode. * @param src the JSON input bytes. * @return the JSON node. */ public static JsonNode parse(byte[] src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Parses a String representing a json, and return it as a JsonNode. * @param src the JSON string. * @return the JSON node. */ public static JsonNode parse(String src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Parses a byte array representing a json, and return it as a JsonNode. * @param src the JSON input bytes. * @return the JSON node. */ public static JsonNode parse(byte[] src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Parses a String representing a json, and return it as a JsonNode. * @param src the JSON string. * @return the JSON node. */ public static JsonNode parse(String src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Converts an object to JsonNode. * * @param data Value to convert in Json. * @return the JSON node. */ public static JsonNode toJson(final Object data) { try { return mapper().valueToTree(data); } catch(Exception e) { throw new RuntimeException(e); } }
/** * Parses a InputStream representing a json, and return it as a JsonNode. * @param src the JSON input stream. * @return the JSON node. */ public static JsonNode parse(java.io.InputStream src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Parses a InputStream representing a json, and return it as a JsonNode. * @param src the JSON input stream. * @return the JSON node. */ public static JsonNode parse(java.io.InputStream src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Parses a String representing a json, and return it as a JsonNode. * @param src the JSON string. * @return the JSON node. */ public static JsonNode parse(String src) { try { return mapper().readTree(src); } catch(Throwable t) { throw new RuntimeException(t); } }
/** * Converts an object to JsonNode. * * @param data Value to convert in Json. * @return the JSON node. */ public static JsonNode toJson(final Object data) { try { return mapper().valueToTree(data); } catch(Exception e) { throw new RuntimeException(e); } }
/** * Converts a JsonNode to a Java value * * @param <A> the type of the return value. * @param json Json value to convert. * @param clazz Expected Java value type. * @return the return value. */ public static <A> A fromJson(JsonNode json, Class<A> clazz) { try { return mapper().treeToValue(json, clazz); } catch(Exception e) { throw new RuntimeException(e); } }
/** * Creates a new empty ArrayNode. * @return a new empty ArrayNode. */ public static ArrayNode newArray() { return mapper().createArrayNode(); }
/** * Creates a new empty ArrayNode. * @return a new empty ArrayNode. */ public static ArrayNode newArray() { return mapper().createArrayNode(); }
/** * Creates a new empty ArrayNode. * @return a new empty ArrayNode. */ public static ArrayNode newArray() { return mapper().createArrayNode(); }
private static String generateJson(Object o, boolean prettyPrint, boolean escapeNonASCII) { try { ObjectWriter writer = mapper().writer(); if (prettyPrint) { writer = writer.with(SerializationFeature.INDENT_OUTPUT); } if (escapeNonASCII) { writer = writer.with(Feature.ESCAPE_NON_ASCII); } return writer.writeValueAsString(o); } catch (IOException e) { throw new RuntimeException(e); } }