net.minidev.json.JSONObject.getAsNumber()方法的使用及代码示例

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

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

JSONObject.getAsNumber介绍

[英]A Simple Helper cast an Object to an Number
[中]简单的辅助对象将对象强制转换为数字

代码示例

代码示例来源:origin: ScienJus/pixiv-crawler

/**
 * 获得排行榜下一页页数
 * @param json
 * @return
 */
public int parseRankNextPage(JSONObject json) {
  Number nextPage = json.getAsNumber("next");
  if (nextPage == null) {
    return -1;
  }
  return nextPage.intValue();
}

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

case INT1:
case INT2:
 Number int2Num = object.getAsNumber(fieldName);
 if (int2Num != null) {
  output.put(fieldIndex, DatumFactory.createInt2(int2Num.shortValue()));
 Number int4Num = object.getAsNumber(fieldName);
 if (int4Num != null) {
  output.put(fieldIndex, DatumFactory.createInt4(int4Num.intValue()));
 Number int8Num = object.getAsNumber(fieldName);
 if (int8Num != null) {
  output.put(fieldIndex, DatumFactory.createInt8(int8Num.longValue()));
 Number float4Num = object.getAsNumber(fieldName);
 if (float4Num != null) {
  output.put(fieldIndex, DatumFactory.createFloat4(float4Num.floatValue()));
 Number float8Num = object.getAsNumber(fieldName);
 if (float8Num != null) {
  output.put(fieldIndex, DatumFactory.createFloat8(float8Num.doubleValue()));

代码示例来源:origin: org.apache.tajo/tajo-storage-hdfs

case INT1:
case INT2:
 Number int2Num = object.getAsNumber(fieldName);
 if (int2Num != null) {
  output.put(fieldIndex, DatumFactory.createInt2(int2Num.shortValue()));
 Number int4Num = object.getAsNumber(fieldName);
 if (int4Num != null) {
  output.put(fieldIndex, DatumFactory.createInt4(int4Num.intValue()));
 Number int8Num = object.getAsNumber(fieldName);
 if (int8Num != null) {
  output.put(fieldIndex, DatumFactory.createInt8(int8Num.longValue()));
 Number float4Num = object.getAsNumber(fieldName);
 if (float4Num != null) {
  output.put(fieldIndex, DatumFactory.createFloat4(float4Num.floatValue()));
 Number float8Num = object.getAsNumber(fieldName);
 if (float8Num != null) {
  output.put(fieldIndex, DatumFactory.createFloat8(float8Num.doubleValue()));

相关文章