本文整理了Java中org.codehaus.jettison.json.JSONArray.getDouble()
方法的一些代码示例,展示了JSONArray.getDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.getDouble()
方法的具体详情如下:
包路径:org.codehaus.jettison.json.JSONArray
类名称:JSONArray
方法名:getDouble
[英]Get the double value associated with an index.
[中]获取与索引关联的双精度值。
代码示例来源:origin: org.codehaus.jettison/jettison
/**
* Get the optional double 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 subscript
* @param defaultValue The default value.
* @return The value.
*/
public double optDouble(int index, double defaultValue) {
try {
return getDouble(index);
} catch (Exception e) {
return defaultValue;
}
}
代码示例来源:origin: org.codehaus.jettison/jettison
/**
* Get the long value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
*/
public long getLong(int index) throws JSONException {
Object o = get(index);
return o instanceof Number ?
((Number)o).longValue() : (long)getDouble(index);
}
代码示例来源:origin: org.codehaus.jettison/jettison
/**
* Get the int value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
* if the value cannot be converted to a number.
*/
public int getInt(int index) throws JSONException {
Object o = get(index);
return o instanceof Number ?
((Number)o).intValue() : (int)getDouble(index);
}
代码示例来源:origin: org.codehaus.jettison/com.springsource.org.codehaus.jettison
/**
* Get the optional double 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 subscript
* @param defaultValue The default value.
* @return The value.
*/
public double optDouble(int index, double defaultValue) {
try {
return getDouble(index);
} catch (Exception e) {
return defaultValue;
}
}
代码示例来源:origin: org.codehaus.jettison/com.springsource.org.codehaus.jettison
/**
* Get the long value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
*/
public long getLong(int index) throws JSONException {
Object o = get(index);
return o instanceof Number ?
((Number)o).longValue() : (long)getDouble(index);
}
代码示例来源:origin: org.apache.apex/malhar-library
@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
Float val;
try {
val = (float)jo.getDouble(index);
} catch (JSONException ex) {
throw new IllegalArgumentException("The key " + field + " does not have a valid double value.", ex);
}
gpo.setFieldGeneric(field, val);
}
代码示例来源:origin: org.apache.apex/malhar-library
@Override
public void setFieldFromJSON(GPOMutable gpo, String field, JSONArray jo, int index)
{
Double val;
try {
val = jo.getDouble(index);
} catch (JSONException ex) {
throw new IllegalArgumentException("The key " + field + " does not have a valid double value.", ex);
}
gpo.setFieldGeneric(field, val);
}
代码示例来源:origin: org.codehaus.jettison/com.springsource.org.codehaus.jettison
/**
* Get the int value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
* if the value cannot be converted to a number.
*/
public int getInt(int index) throws JSONException {
Object o = get(index);
return o instanceof Number ?
((Number)o).intValue() : (int)getDouble(index);
}
代码示例来源:origin: org.apache.apex/malhar-library
return ja.getDouble(index);
} catch (JSONException ex) {
throw new IllegalArgumentException("The index "
return (float)ja.getDouble(index);
} catch (JSONException ex) {
throw new IllegalArgumentException("The index "
代码示例来源:origin: org.jspresso.framework/jspresso-swing-application
@Override
public void valueChange(ValueChangeEvent evt) {
String mapContent = mapContentConnector.getConnectorValue();
if (mapContent != null) {
try {
JSONObject mapContentAsJson = new JSONObject(mapContent);
JSONArray markers = mapContentAsJson.optJSONArray(MapHelper.MARKERS_KEY);
if (markers != null && markers.length() > 0) {
JSONArray marker = markers.getJSONArray(0);
mapView.setCenter(marker.getDouble(1), marker.getDouble(0));
mapView.setVisible(true);
} else {
mapView.setVisible(false);
}
} catch (JSONException e) {
throw new ConnectorBindingException(e, "Invalid Json map content");
}
} else {
mapView.setVisible(false);
}
}
};
代码示例来源: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");
}
内容来源于网络,如有侵权,请联系作者删除!