/** * Factory method for constructing a wrapper for POJO * ("Plain Old Java Object") objects; these will get serialized * using data binding, usually as JSON Objects, but in some * cases as JSON Strings or other node types. */ public POJONode POJONode(Object pojo) { return new POJONode(pojo); } }
@Override public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { // Multiple possibilities... JsonNode n = currentNode(); if (n != null) { // binary node? byte[] data = n.getBinaryValue(); // (or TextNode, which can also convert automatically!) if (data != null) { return data; } // Or maybe byte[] as POJO? if (n.isPojo()) { Object ob = ((POJONode) n).getPojo(); if (ob instanceof byte[]) { return (byte[]) ob; } } } // otherwise return null to mark we have no binary content return null; }
/** * Factory method for constructing a wrapper for POJO * ("Plain Old Java Object") objects; these will get serialized * using data binding, usually as JSON Objects, but in some * cases as JSON Strings or other node types. */ public POJONode POJONode(Object pojo) { return new POJONode(pojo); } }
@Override public Object getEmbeddedObject() { if (!_closed) { JsonNode n = currentNode(); if (n != null) { if (n.isPojo()) { return ((POJONode) n).getPojo(); } if (n.isBinary()) { return ((BinaryNode) n).getBinaryValue(); } } } return null; }
/** * Factory method for constructing a wrapper for POJO * ("Plain Old Java Object") objects; these will get serialized * using data binding, usually as JSON Objects, but in some * cases as JSON Strings or other node types. */ public POJONode POJONode(Object pojo) { return new POJONode(pojo); } }
@Override public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { // Multiple possibilities... JsonNode n = currentNode(); if (n != null) { // binary node? byte[] data = n.getBinaryValue(); // (or TextNode, which can also convert automatically!) if (data != null) { return data; } // Or maybe byte[] as POJO? if (n.isPojo()) { Object ob = ((POJONode) n).getPojo(); if (ob instanceof byte[]) { return (byte[]) ob; } } } // otherwise return null to mark we have no binary content return null; }
/** * Factory method for constructing a wrapper for POJO * ("Plain Old Java Object") objects; these will get serialized * using data binding, usually as JSON Objects, but in some * cases as JSON Strings or other node types. */ public POJONode POJONode(Object pojo) { return new POJONode(pojo); } }
@Override public Object getEmbeddedObject() { if (!_closed) { JsonNode n = currentNode(); if (n != null) { if (n.isPojo()) { return ((POJONode) n).getPojo(); } if (n.isBinary()) { return ((BinaryNode) n).getBinaryValue(); } } } return null; }
/** * Factory method for constructing a wrapper for POJO * ("Plain Old Java Object") objects; these will get serialized * using data binding, usually as JSON Objects, but in some * cases as JSON Strings or other node types. */ public POJONode POJONode(Object pojo) { return new POJONode(pojo); } }
@Override public Object getEmbeddedObject() { if (!_closed) { JsonNode n = currentNode(); if (n != null && n.isPojo()) { return ((POJONode) n).getPojo(); } } return null; }
public JsonRepresentation arrayAdd(final Object value) { if (!isArray()) { throw new IllegalStateException("does not represent array"); } asArrayNode().add(new POJONode(value)); return this; }
@Override public Object getEmbeddedObject() { if (!_closed) { JsonNode n = currentNode(); if (n != null && n.isPojo()) { return ((POJONode) n).getPojo(); } } return null; }
public void arrayAdd(final Object value) { if (!isArray()) { throw new IllegalStateException("does not represent array"); } asArrayNode().add(new POJONode(value)); }
Object pojo = ((POJONode) thisNode).getPojo(); BeanInfo info = Introspector.getBeanInfo(pojo.getClass()); for (PropertyDescriptor pd : info.getPropertyDescriptors())
@SuppressWarnings("unchecked") public static ValueNode toValueNode(final Object value){ if(value == null) return getFactory().nullNode(); final ValueNodeConverter converter = converters.get(value.getClass()); return converter == null ? new POJONode(value) : converter.apply(getFactory(), value); } }
@Override public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { // Multiple possibilities... JsonNode n = currentNode(); if (n != null) { // binary node? byte[] data = n.getBinaryValue(); // (or TextNode, which can also convert automatically!) if (data != null) { return data; } // Or maybe byte[] as POJO? if (n.isPojo()) { Object ob = ((POJONode) n).getPojo(); if (ob instanceof byte[]) { return (byte[]) ob; } } } // otherwise return null to mark we have no binary content return null; }
public void mapPut(final String key, final Object value) { if (!isMap()) { throw new IllegalStateException("does not represent map"); } if (value == null) { return; } final Path path = Path.parse(key); final ObjectNode node = JsonNodeUtils.walkNodeUpTo(asObjectNode(), path.getHead()); node.put(path.getTail(), new POJONode(value)); }
@Override public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { // Multiple possibilities... JsonNode n = currentNode(); if (n != null) { // binary node? byte[] data = n.getBinaryValue(); // (or TextNode, which can also convert automatically!) if (data != null) { return data; } // Or maybe byte[] as POJO? if (n.isPojo()) { Object ob = ((POJONode) n).getPojo(); if (ob instanceof byte[]) { return (byte[]) ob; } } } // otherwise return null to mark we have no binary content return null; }
public JsonRepresentation mapPut(final String key, final Object value) { if (!isMap()) { throw new IllegalStateException("does not represent map"); } final Path path = Path.parse(key); final ObjectNode node = JsonNodeUtils.walkNodeUpTo(asObjectNode(), path.getHead()); node.put(path.getTail(), value != null ? new POJONode(value) : NullNode.getInstance()); return this; }
@Override public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException { // Multiple possibilities... JsonNode n = currentNode(); if (n != null) { // binary node? byte[] data = n.getBinaryValue(); // (or TextNode, which can also convert automatically!) if (data != null) { return data; } // Or maybe byte[] as POJO? if (n.isPojo()) { Object ob = ((POJONode) n).getPojo(); if (ob instanceof byte[]) { return (byte[]) ob; } } } // otherwise return null to mark we have no binary content return null; }