@Override public Number getNumberValue() throws IOException, JsonParseException { return currentNumericNode().getNumberValue(); }
@Override public String getText() { if (_closed) { return null; } // need to separate handling a bit... switch (_currToken) { case FIELD_NAME: return _nodeCursor.getCurrentName(); case VALUE_STRING: return currentNode().getTextValue(); case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: return String.valueOf(currentNode().getNumberValue()); case VALUE_EMBEDDED_OBJECT: JsonNode n = currentNode(); if (n != null && n.isBinary()) { // this will convert it to base64 return n.asText(); } } return (_currToken == null) ? null : _currToken.asString(); }
return fieldNode.getNumberValue();
assertEquals( "http://base.uri/node/0", jsonNode.get( "self" ).getTextValue() ); assertEquals( "http://base.uri/relationship/0", jsonRel.get( "self" ).getTextValue() ); assertEquals( 2, jsonPath.get( "length" ).getNumberValue() ); assertEquals( "http://base.uri/node/0", jsonPath.get( "start" ).getTextValue() ); assertEquals( "http://base.uri/node/2", jsonPath.get( "end" ).getTextValue() );
return fieldNode.getNumberValue();
private static void assertJsonEquals( String message, Object expected, JsonNode actual ) { if ( expected == null ) { assertTrue( message, actual == null || actual.isNull() ); } else if ( expected instanceof String ) { assertEquals( message, expected, actual.getTextValue() ); } else if ( expected instanceof Number ) { assertEquals( message, expected, actual.getNumberValue() ); } else { fail( message + " - unexpected type - " + expected ); } }
@Override public Number getNumberValue() throws IOException, JsonParseException { return currentNumericNode().getNumberValue(); }
@Override public String getText() { if (_closed) { return null; } // need to separate handling a bit... switch (_currToken) { case FIELD_NAME: return _nodeCursor.getCurrentName(); case VALUE_STRING: return currentNode().getTextValue(); case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: return String.valueOf(currentNode().getNumberValue()); case VALUE_EMBEDDED_OBJECT: JsonNode n = currentNode(); if (n != null && n.isBinary()) { // this will convert it to base64 return n.asText(); } } return (_currToken == null) ? null : _currToken.asString(); }
public Number getNumberValue() { return delegate.getNumberValue(); }
@Override public Number getNumberValue() throws IOException, JsonParseException { return currentNumericNode().getNumberValue(); }
@Override public Number getNumberValue() throws IOException, JsonParseException { return currentNumericNode().getNumberValue(); }
@Override public Number getNumberValue() throws IOException, JsonParseException { return currentNumericNode().getNumberValue(); }
private Short getShort(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an short"); if (!node.isNumber()) { // there is no node.isShort() throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().shortValue(); }
private Float getFloat(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a float"); if (!node.isNumber()) { throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().floatValue(); }
private Byte getByte(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an byte"); if (!node.isNumber()) { // there is no node.isByte() throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().byteValue(); }
private Object extractId(JsonNode idNode) { if (idNode == null) return null; if (idNode.isNumber()) return idNode.getNumberValue(); if (idNode.isTextual()) return idNode.getTextValue(); if (idNode.isNull()) return null; throw new IllegalArgumentException("Not a valid id type: " + idNode); } }
private Number getNumber(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a number"); if (!node.isNumber()) { throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue(); }
/** * Converts a JSON string or integer node into a Java object (String, Integer or Long). * * @param node JSON string or integer numeric node. * @return the JSON value, as a String, an Integer or a Long instance. * @throws IOException if the JSON node is neither a string nor an integer value. */ private static Object getJsonStringOrIntValue(JsonNode node) throws IOException { if (node.isInt() || node.isLong()) { return node.getNumberValue(); } else if (node.isTextual()) { return node.getTextValue(); } else if (node.isNull()) { return null; } else { throw new IOException(String.format( "Invalid JSON value: '%s', expecting string, int, long, or null.", node)); } }
void assertEntryEquals(ContainerNode rootNode, String key, long value) { JsonNode node = assertNodeContains(rootNode, key); assertEquals(value, node.getNumberValue()); }
void assertEntryEquals(ContainerNode rootNode, String key, long value) { JsonNode node = assertNodeContains(rootNode, key); assertEquals(value, node.getNumberValue()); }