org.codehaus.jackson.JsonNode.getNumberValue()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.codehaus.jackson.JsonNode.getNumberValue()方法的一些代码示例,展示了JsonNode.getNumberValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.getNumberValue()方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:getNumberValue

JsonNode.getNumberValue介绍

[英]Returns numeric value for this node, if and only if this node is numeric ( #isNumber returns true); otherwise returns null
[中]返回此节点的数值,当且仅当此节点为数值时(#isNumber返回true);否则返回null

代码示例

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public Number getNumberValue() throws IOException, JsonParseException {
  return currentNumericNode().getNumberValue();
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@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();
}

代码示例来源:origin: apache/nifi

return fieldNode.getNumberValue();

代码示例来源:origin: neo4j/neo4j

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() );

代码示例来源:origin: apache/nifi

return fieldNode.getNumberValue();

代码示例来源:origin: neo4j/neo4j

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 );
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public Number getNumberValue() throws IOException, JsonParseException {
  return currentNumericNode().getNumberValue();
}

代码示例来源:origin: camunda/camunda-bpm-platform

@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();
}

代码示例来源:origin: com.atlassian.jira/jira-core

public Number getNumberValue()
{
  return delegate.getNumberValue();
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

@Override
public Number getNumberValue() throws IOException, JsonParseException {
  return currentNumericNode().getNumberValue();
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

@Override
public Number getNumberValue() throws IOException, JsonParseException {
  return currentNumericNode().getNumberValue();
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

@Override
public Number getNumberValue() throws IOException, JsonParseException {
  return currentNumericNode().getNumberValue();
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

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();
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

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();
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

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();
}

代码示例来源:origin: com.atlassian.voorhees/atlassian-voorhees

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);
  }
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

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();
}

代码示例来源:origin: com.moz.fiji.schema/fiji-schema

/**
 * 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));
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

void assertEntryEquals(ContainerNode rootNode, String key, long value) {
 JsonNode node = assertNodeContains(rootNode, key);
 assertEquals(value, node.getNumberValue());
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

void assertEntryEquals(ContainerNode rootNode, String key, long value) {
 JsonNode node = assertNodeContains(rootNode, key);
 assertEquals(value, node.getNumberValue());
}

相关文章