org.codehaus.jettison.json.JSONArray.getLong()方法的使用及代码示例

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

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

JSONArray.getLong介绍

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

代码示例

代码示例来源:origin: org.codehaus.jettison/jettison

/**
 * 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: org.codehaus.jettison/com.springsource.org.codehaus.jettison

/**
 * 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: org.apache.apex/malhar-library

@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
 long val;
 try {
  val = jo.getLong(index);
 } catch (JSONException ex) {
  throw new IllegalArgumentException("The key " + field + " does not have a valid long value.", ex);
 }
 gpo.setField(field, val);
}

代码示例来源:origin: org.apache.apex/malhar-library

@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
 long val;
 try {
  val = jo.getLong(index);
 } catch (JSONException ex) {
  throw new IllegalArgumentException("The key " + field + " does not have a valid long value.", ex);
 }
 gpo.setField(field, val);
}

代码示例来源:origin: org.apache.apex/malhar-library

} else if (type == Type.LONG) {
 try {
  return ja.getLong(index);
 } catch (JSONException ex) {
  throw new IllegalArgumentException("The index "

代码示例来源:origin: eclipse-ee4j/glassfish

private boolean sameScalar(ScalarValue want, JSONArray parent, int index) throws Exception {
  trace("comparing array scalar element " + index);
  String regexp = want.getRegexp();
  if (want instanceof StringValue) {
    return sameString(((StringValue) want).getValue(), regexp, parent.getString(index));
  }
  if (want instanceof LongValue) {
    return sameString(longToString(((LongValue) want).getValue()), regexp, longToString(parent.getLong(index)));
  }
  if (want instanceof IntValue) {
    return sameString(intToString(((IntValue) want).getValue()), regexp, intToString(parent.getInt(index)));
  }
  if (want instanceof DoubleValue) {
    return sameString(doubleToString(((DoubleValue) want).getValue()), regexp, doubleToString(parent.getDouble(index)));
  }
  if (want instanceof BooleanValue) {
    return sameString(booleanToString(((BooleanValue) want).getValue()), regexp, booleanToString(parent.getBoolean(index)));
  }
  throw new AssertionError(want + " is not a valid scalar type.  Valid types are string, long, int, double, boolean");
}

代码示例来源:origin: inchaincodes/inchain

try {
    if(params.length() == 1) {
      height = params.getLong(0);
      height = params.getLong(0);
      try {
        confirm = params.getLong(1);
      }catch (Exception e) {
        address = params.getString(1);
      height = params.getLong(0);
      confirm = params.getLong(1);
      address = params.getString(2);
  long lockTime = params.getLong(2);
Long amount;
try {
  amount =  params.getLong(2);
}catch (Exception e) {
  result.put("success", false);
Long amount;
try {
  amount =  params.getLong(2);
}catch (Exception e) {
  result.put("success", false);

相关文章