org.apache.sling.commons.json.JSONArray.getLong()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(0.9k)|赞(0)|评价(0)|浏览(120)

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

JSONArray.getLong介绍

[英]Get the long value associated with an index.
[中]获取与索引关联的长值。

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json

/**
 * Get the optional long value associated with an index.
 * The defaultValue is returned if there is no value for the index,
 * or if the value is not a number and cannot be converted to a number.
 * @param index The index must be between 0 and length() - 1.
 * @param defaultValue     The default value.
 * @return      The value.
 */
public long optLong(int index, long defaultValue) {
  try {
    return getLong(index);
  } catch (Exception e) {
    return defaultValue;
  }
}

代码示例来源:origin: io.wcm/io.wcm.caconfig.editor

long[] values = new long[array.length()];
for (int i = 0; i < values.length; i++) {
 values[i] = array.getLong(i);

相关文章