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

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

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

JSONArray.opt介绍

[英]Get the optional object value associated with an index.
[中]获取与索引关联的可选对象值。

代码示例

代码示例来源:origin: json-path/JsonPath

@Override
public Object getArrayIndex(Object obj, int index)
{
  return jettisonUnwrap(((org.codehaus.jettison.json.JSONArray)obj).opt(index));
}

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

/**
 * Get the optional JSONArray associated with an index.
 * @param index subscript
 * @return      A JSONArray value, or null if the index has no value,
 * or if the value is not a JSONArray.
 */
public JSONArray optJSONArray(int index) {
  Object o = opt(index);
  return o instanceof JSONArray ? (JSONArray)o : null;
}

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

/**
 * Get the optional JSONObject associated with an index.
 * Null is returned if the key is not found, or null if the index has
 * no value, or if the value is not a JSONObject.
 *
 * @param index The index must be between 0 and length() - 1.
 * @return      A JSONObject value.
 */
public JSONObject optJSONObject(int index) {
  Object o = opt(index);
  return o instanceof JSONObject ? (JSONObject)o : null;
}

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

/**
 * Get the optional string associated with an index.
 * The defaultValue is returned if the key is not found.
 *
 * @param index The index must be between 0 and length() - 1.
 * @param defaultValue     The default value.
 * @return      A String value.
 */
public String optString(int index, String defaultValue) {
  Object o = opt(index);
  return o != null ? o.toString() : defaultValue;
}

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

/**
 * Determine if the value is null.
 * @param index The index must be between 0 and length() - 1.
 * @return true if the value at the index is null, or if there is no value.
 */
public boolean isNull(int index) {
  return JSONObject.NULL.equals(opt(index));
}

代码示例来源:origin: com.jayway.jsonpath/json-path

@Override
public Object getArrayIndex(Object obj, int index)
{
  return jettisonUnwrap(((org.codehaus.jettison.json.JSONArray)obj).opt(index));
}

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

/**
 * Get the object value associated with an index.
 * @param index
 *  The index must be between 0 and length() - 1.
 * @return An object value.
 * @throws JSONException If there is no value for the index.
 */
public Object get(int index) throws JSONException {
  Object o = opt(index);
  if (o == null) {
    throw new JSONException("JSONArray[" + index + "] not found.");
  }
  return o;
}

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

/**
 * Produce a JSONObject by combining a JSONArray of names with the values
 * of this JSONArray.
 * @param names A JSONArray containing a list of key strings. These will be
 * paired with the values.
 * @return A JSONObject, or null if there are no names or if this JSONArray
 * has no values.
 * @throws JSONException If any of the names are null.
 */
public JSONObject toJSONObject(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0 || length() == 0) {
    return null;
  }
  JSONObject jo = new JSONObject();
  for (int i = 0; i < names.length(); i += 1) {
    jo.put(names.getString(i), this.opt(i));
  }
  return jo;
}

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

/**
 * Get the optional JSONArray associated with an index.
 * @param index subscript
 * @return      A JSONArray value, or null if the index has no value,
 * or if the value is not a JSONArray.
 */
public JSONArray optJSONArray(int index) {
  Object o = opt(index);
  return o instanceof JSONArray ? (JSONArray)o : null;
}

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

/**
 * Get the optional JSONObject associated with an index.
 * Null is returned if the key is not found, or null if the index has
 * no value, or if the value is not a JSONObject.
 *
 * @param index The index must be between 0 and length() - 1.
 * @return      A JSONObject value.
 */
public JSONObject optJSONObject(int index) {
  Object o = opt(index);
  return o instanceof JSONObject ? (JSONObject)o : null;
}

代码示例来源:origin: org.compass-project/compass

public Object opt(int index) {
    return jsonArray.opt(index);
  }
}

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

/**
 * Determine if the value is null.
 * @param index The index must be between 0 and length() - 1.
 * @return true if the value at the index is null, or if there is no value.
 */
public boolean isNull(int index) {
  return JSONObject.NULL.equals(opt(index));
}

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

/**
 * Get the optional string associated with an index.
 * The defaultValue is returned if the key is not found.
 *
 * @param index The index must be between 0 and length() - 1.
 * @param defaultValue     The default value.
 * @return      A String value.
 */
public String optString(int index, String defaultValue) {
  Object o = opt(index);
  return o != null ? o.toString() : defaultValue;
}

代码示例来源:origin: com.github.lafa.jsonpath/json-path

@Override
public Object getArrayIndex(Object obj, int index)
{
  return jettisonUnwrap(((org.codehaus.jettison.json.JSONArray)obj).opt(index));
}

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

/**
 * Get the object value associated with an index.
 * @param index
 *  The index must be between 0 and length() - 1.
 * @return An object value.
 * @throws JSONException If there is no value for the index.
 */
public Object get(int index) throws JSONException {
  Object o = opt(index);
  if (o == null) {
    throw new JSONException("JSONArray[" + index + "] not found.");
  }
  return o;
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-rexster-graph

public Object vertexIds() {
  final String directionReturnToken;
  if (this.direction == Direction.IN) {
    directionReturnToken = RexsterTokens.SLASH_INIDS;
  } else if (this.direction == Direction.OUT) {
    directionReturnToken = RexsterTokens.SLASH_OUTIDS;
  } else {
    directionReturnToken = RexsterTokens.SLASH_BOTHIDS;
  }
  final JSONArray jsonArray = RestHelper.getResultArray(buildUri(directionReturnToken));
  final List<Object> list = new ArrayList<Object>();
  for (int ix = 0; ix < jsonArray.length(); ix++) {
    list.add(jsonArray.opt(ix));
  }
  return list;
}

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

jValue = jValueArray.opt(j);
if(jValue instanceof JSONObject){

代码示例来源:origin: com.tinkerpop.rexster/rexster-core

typedItems.add(getTypedPropertyValue(innerJson.opt(ix), parseTypes));

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

/**
 * Produce a JSONObject by combining a JSONArray of names with the values
 * of this JSONArray.
 * @param names A JSONArray containing a list of key strings. These will be
 * paired with the values.
 * @return A JSONObject, or null if there are no names or if this JSONArray
 * has no values.
 * @throws JSONException If any of the names are null.
 */
public JSONObject toJSONObject(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0 || length() == 0) {
    return null;
  }
  JSONObject jo = new JSONObject();
  for (int i = 0; i < names.length(); i += 1) {
    jo.put(names.getString(i), this.opt(i));
  }
  return jo;
}

相关文章