Java Code Examples for org.nd4j.shade.jackson.databind.JsonNode#isLong()
The following examples show how to use
org.nd4j.shade.jackson.databind.JsonNode#isLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataJsonDeserializer.java From konduit-serving with Apache License 2.0 | 5 votes |
protected ValueType nodeType(JsonNode n){ if (n.isTextual()) { //String return ValueType.STRING; } else if (n.isDouble()) { //Double return ValueType.DOUBLE; } else if (n.isInt() || n.isLong()) { //Long return ValueType.INT64; } else if (n.isBoolean()) { //Boolean return ValueType.BOOLEAN; } else if (n.isArray()){ return ValueType.LIST; } else if (n.isObject()) { //Could be: Bytes, image, NDArray, BoundingBox, Point or Data if (n.has(Data.RESERVED_KEY_BYTES_BASE64)) { return ValueType.BYTES; } else if (n.has(Data.RESERVED_KEY_BYTES_ARRAY)) { return ValueType.BYTES; } else if (n.has(Data.RESERVED_KEY_NDARRAY_TYPE)) { //NDArray return ValueType.NDARRAY; } else if (n.has(Data.RESERVED_KEY_IMAGE_DATA)) { //Image return ValueType.IMAGE; } else if(n.has(Data.RESERVED_KEY_BB_CX) || n.has(Data.RESERVED_KEY_BB_X1)){ return ValueType.BOUNDING_BOX; } else if(n.has(Data.RESERVED_KEY_POINT_COORDS)){ return ValueType.POINT; } else { //Must be data return ValueType.DATA; } } else { throw new UnsupportedOperationException("Type not yet implemented"); } }
Example 2
Source File: DataJsonDeserializer.java From konduit-serving with Apache License 2.0 | 4 votes |
public Data deserialize(JsonParser jp, JsonNode n) { JData d = new JData(); Iterator<String> names = n.fieldNames(); while (names.hasNext()) { String s = names.next(); JsonNode n2 = n.get(s); if (Data.RESERVED_KEY_METADATA.equalsIgnoreCase(s)) { Data meta = deserialize(jp, n2); d.setMetaData(meta); } else { if (n2.isTextual()) { //String String str = n2.textValue(); d.put(s, str); } else if (n2.isDouble()) { //Double double dVal = n2.doubleValue(); d.put(s, dVal); } else if (n2.isInt() || n2.isLong()) { //Long long lVal = n2.longValue(); d.put(s, lVal); } else if (n2.isBoolean()) { //Boolean boolean b = n2.booleanValue(); d.put(s, b); } else if (n2.isArray()){ Pair<List<Object>, ValueType> p = deserializeList(jp, n2); d.putList(s, p.getFirst(), p.getSecond()); } else if (n2.isObject()) { //Could be: Bytes, image, NDArray, BoundingBox, Point or Data if (n2.has(Data.RESERVED_KEY_BYTES_BASE64) || n2.has(Data.RESERVED_KEY_BYTES_ARRAY)) { //byte[] stored in base64 or byte[] as JSON array byte[] bytes = deserializeBytes(n2); d.put(s, bytes); } else if (n2.has(Data.RESERVED_KEY_NDARRAY_TYPE)) { //NDArray d.put(s, deserializeNDArray(n2)); } else if (n2.has(Data.RESERVED_KEY_IMAGE_DATA)) { //Image d.put(s, deserializeImage(n2)); } else if(n2.has(Data.RESERVED_KEY_BB_CY) || n2.has(Data.RESERVED_KEY_BB_X1)){ d.put(s, deserializeBB(n2)); } else if(n2.has(Data.RESERVED_KEY_POINT_COORDS)){ d.put(s, deserializePoint(n2)); } else { //Must be data Data dInner = deserialize(jp, n2); d.put(s, dInner); } } else { throw new UnsupportedOperationException("Type not yet implemented"); } } } return d; }