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

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

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

JsonNode.asLong介绍

[英]Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation can not be converted to an long (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.
[中]方法,该方法将尝试将此节点的值转换为Java long。使用默认Java规则强制数字;布尔值转换为0(false)和1(true),字符串使用默认的Java语言整数解析规则进行解析。
如果无法将表示转换为long(包括对象和数组等结构化类型),则返回默认值0;没有抛出异常。

代码示例

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

/**
 * Method that will try to convert value of this node to a Java <b>long</b>.
 * Numbers are coerced using default Java rules; booleans convert to 0 (false)
 * and 1 (true), and Strings are parsed using default Java language integer
 * parsing rules.
 *<p>
 * If representation can not be converted to an long (including structured types
 * like Objects and Arrays),
 * default value of <b>0</b> will be returned; no exceptions are thrown.
 * 
 * @since 1.9 (replaces <code>getValueAsLong</code>)
 */
public long asLong() {
  return asLong(0L);
}

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

/**
 * Method that will try to convert value of this node to a Java <b>long</b>.
 * Numbers are coerced using default Java rules; booleans convert to 0 (false)
 * and 1 (true), and Strings are parsed using default Java language integer
 * parsing rules.
 *<p>
 * If representation can not be converted to an long (including structured types
 * like Objects and Arrays),
 * default value of <b>0</b> will be returned; no exceptions are thrown.
 * 
 * @since 1.6
 * 
 * @deprecated Since 1.9, use {@link #asLong} instead
 */
@Deprecated
public long getValueAsLong() { return asLong(0L); }

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

/**
 * Method that will try to convert value of this node to a Java <b>long</b>.
 * Numbers are coerced using default Java rules; booleans convert to 0 (false)
 * and 1 (true), and Strings are parsed using default Java language integer
 * parsing rules.
 *<p>
 * If representation can not be converted to an long (including structured types
 * like Objects and Arrays),
 * specified <b>defaultValue</b> will be returned; no exceptions are thrown.
 * 
 * @since 1.6
 * 
 * @deprecated Since 1.9, use {@link #asLong} instead
 */
@Deprecated
public long getValueAsLong(long defaultValue) { return asLong(defaultValue); }

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

private void assertQueryGetsValue( ServerControls server, String query, long value ) throws Throwable
{
  HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
      quotedJson( "{ 'statements': [ { 'statement': '" + query + "' } ] }" ) );
  assertEquals( "[]", response.get( "errors" ).toString() );
  JsonNode result = response.get( "results" ).get( 0 );
  assertEquals( "value", result.get( "columns" ).get( 0 ).asText() );
  assertEquals( value, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asLong() );
}

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

private void assertQueryGetsValue( ServerControls server, String query, long value ) throws Throwable
{
  HTTP.Response response = HTTP.POST( server.httpURI().resolve( "db/data/transaction/commit" ).toString(),
      quotedJson( "{ 'statements': [ { 'statement': '" + query + "' } ] }" ) );
  assertEquals( "[]", response.get( "errors" ).toString() );
  JsonNode result = response.get( "results" ).get( 0 );
  assertEquals( "value", result.get( "columns" ).get( 0 ).asText() );
  assertEquals( value, result.get( "data" ).get( 0 ).get( "row" ).get( 0 ).asLong() );
}

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

return node.asInt();
} else if (node.isLong()) {
 return node.asLong();
} else if (node.isDouble()) {
 return node.asDouble();

代码示例来源:origin: org.apache.avro/avro

return jsonNode.asInt();
 } else if (schema.getType().equals(Schema.Type.LONG)) {
  return jsonNode.asLong();
 return jsonNode.asLong();
} else if (jsonNode.isDouble()) {
 if (schema == null || schema.getType().equals(Schema.Type.DOUBLE)) {

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

/**
 * Method that will try to convert value of this node to a Java <b>long</b>.
 * Numbers are coerced using default Java rules; booleans convert to 0 (false)
 * and 1 (true), and Strings are parsed using default Java language integer
 * parsing rules.
 *<p>
 * If representation can not be converted to an long (including structured types
 * like Objects and Arrays),
 * default value of <b>0</b> will be returned; no exceptions are thrown.
 * 
 * @since 1.9 (replaces <code>getValueAsLong</code>)
 */
public long asLong() {
  return asLong(0L);
}

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

assertEquals( 0, root.get( "id" ).asLong() );
assertEquals( asSet( parentId ), identifiersOf( root ) );

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

/**
 * Method that will try to convert value of this node to a Java <b>long</b>.
 * Numbers are coerced using default Java rules; booleans convert to 0 (false)
 * and 1 (true), and Strings are parsed using default Java language integer
 * parsing rules.
 *<p>
 * If representation can not be converted to an long (including structured types
 * like Objects and Arrays),
 * specified <b>defaultValue</b> will be returned; no exceptions are thrown.
 * 
 * @since 1.6
 * 
 * @deprecated Since 1.9, use {@link #asLong} instead
 */
@Deprecated
public long getValueAsLong(long defaultValue) { return asLong(defaultValue); }

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

/**
 * Method that will try to convert value of this node to a Java <b>long</b>.
 * Numbers are coerced using default Java rules; booleans convert to 0 (false)
 * and 1 (true), and Strings are parsed using default Java language integer
 * parsing rules.
 *<p>
 * If representation can not be converted to an long (including structured types
 * like Objects and Arrays),
 * default value of <b>0</b> will be returned; no exceptions are thrown.
 * 
 * @since 1.6
 * 
 * @deprecated Since 1.9, use {@link #asLong} instead
 */
@Deprecated
public long getValueAsLong() { return asLong(0L); }

代码示例来源:origin: kaaproject/kaa

return byDefault.asLong();

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

public long asLong(final long defaultValue)
{
  return delegate.asLong(defaultValue);
}

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

public long asLong()
{
  return delegate.asLong();
}

代码示例来源:origin: CryptoWorldChain/ewallet

public static String setYeAmountToJson(String date) throws JsonProcessingException, IOException{
  JsonNode dataNode = mapper.readTree(date);
  for(JsonNode node:dataNode){
    ((ObjectNode)node).put("extrafield1",node.get("mertrademoney").asLong()-node.get("tradeamount").asLong());
  }
  return dataNode.toString();
}
public static JsonNode dataToJson(String data) throws JsonProcessingException, IOException{

代码示例来源:origin: fi.vm.sade.haku/hakemus-api

private final ObjectId processSplinteredId(final JsonNode treeNode) {
    final long time = treeNode.get("time").asLong();
    final int machine = treeNode.get("machine").asInt();
    final int inc = treeNode.get("inc").asInt();
    final ObjectId objectId = new ObjectId(new Date(time), machine, inc);
    objectId.notNew();
    return objectId;
  }
}

代码示例来源:origin: CryptoWorldChain/ewallet

public static String jsonLongTimeToDate(String data,String timedata) throws JsonProcessingException, IOException{
  ObjectMapper mapper = new ObjectMapper(); 
  JsonNode dataNode = mapper.readTree(data);
  String []time = timedata.split(",");
  for (JsonNode jsonNode : dataNode) {
    for (String str : time) {
      ((ObjectNode)jsonNode).put(str, (jsonNode.get(str)==null||"".equals(jsonNode.get(str).asText()))?"1970-01-01":DateUtil.format(new Date(jsonNode.get(str).asLong()),DateStyle.YYYY_MM_DD));
    }
  }
  return dataNode.toString();
}

代码示例来源:origin: fi.vm.sade.haku/hakemus-api

@Override
  public ObjectId deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    final ObjectCodec codec = jsonParser.getCodec();
    final JsonNode treeNode = codec.readTree(jsonParser);
    final long time = treeNode.get("time").asLong();
    final int machine = treeNode.get("machine").asInt();
    final int inc = treeNode.get("inc").asInt();

    final ObjectId objectId = new ObjectId(new Date(time), machine, inc);
    objectId.notNew();
    return objectId;
  }
}

代码示例来源:origin: Orange-OpenSource/spring-social-weibo

@Override
public long follow(String trendName) {
  requireAuthorization();
  MultiValueMap<String, String> request = new LinkedMultiValueMap<String, String>(
      1);
  request.add("trend_name", trendName);
  return restTemplate
      .postForObject(buildUri("trends/follow.json"), request,
          JsonNode.class).findValue("topicid").asLong();
}

代码示例来源:origin: io.snamp/json-helpers

@Override
  protected LongBuffer deserialize(final ArrayNode input) throws JsonProcessingException {
    final LongBuffer result = LongBuffer.allocate(input.size());
    for(final JsonNode node: input)
      result.put(node.asLong());
    return result;
  }
}

相关文章