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

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

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

JSONArray.remove介绍

暂无

代码示例

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

@Override
public void removeProperty(Object obj, Object key)
{
  try
  {
    if( obj instanceof org.codehaus.jettison.json.JSONArray )
    {
      int index = key instanceof Integer? (Integer) key : Integer.parseInt(key.toString());
      if( index<length(obj) )
      {
        Object temp = new Object(); // Need FIX: JSONArray.remove(int)
        ((org.codehaus.jettison.json.JSONArray)obj).put(index, temp);
        ((org.codehaus.jettison.json.JSONArray)obj).remove(temp);
      }
    }
    if( obj instanceof org.codehaus.jettison.json.JSONObject )
    {
      ((org.codehaus.jettison.json.JSONObject)obj).remove(String.valueOf(key));
    }
  }
  catch( org.codehaus.jettison.json.JSONException jsonException )
  {
    throw new IllegalStateException(jsonException);
  }
}

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

@Override
public void removeProperty(Object obj, Object key)
{
  try
  {
    if( obj instanceof org.codehaus.jettison.json.JSONArray )
    {
      int index = key instanceof Integer? (Integer) key : Integer.parseInt(key.toString());
      if( index<length(obj) )
      {
        Object temp = new Object(); // Need FIX: JSONArray.remove(int)
        ((org.codehaus.jettison.json.JSONArray)obj).put(index, temp);
        ((org.codehaus.jettison.json.JSONArray)obj).remove(temp);
      }
    }
    if( obj instanceof org.codehaus.jettison.json.JSONObject )
    {
      ((org.codehaus.jettison.json.JSONObject)obj).remove(String.valueOf(key));
    }
  }
  catch( org.codehaus.jettison.json.JSONException jsonException )
  {
    throw new IllegalStateException(jsonException);
  }
}

代码示例来源:origin: cascading/cascading-hadoop2-tez-stats

protected JSONObject getRemoveJsonObject( JSONArray entitiesNode, int index, boolean doRemove )
 {
 try
  {
  JSONObject jsonObject = entitiesNode.getJSONObject( index );
  if( doRemove )
   entitiesNode.remove( jsonObject );
  return jsonObject;
  }
 catch( JSONException exception )
  {
  throw new CascadingException( exception );
  }
 }

代码示例来源:origin: cwensel/cascading

protected JSONObject getRemoveJsonObject( JSONArray entitiesNode, int index, boolean doRemove )
 {
 try
  {
  JSONObject jsonObject = entitiesNode.getJSONObject( index );
  if( doRemove )
   entitiesNode.remove( jsonObject );
  return jsonObject;
  }
 catch( JSONException exception )
  {
  throw new CascadingException( exception );
  }
 }

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

@Override
public void removeProperty(Object obj, Object key)
{
  try
  {
    if( obj instanceof org.codehaus.jettison.json.JSONArray )
    {
      int index = key instanceof Integer? (Integer) key : Integer.parseInt(key.toString());
      if( index<length(obj) )
      {
        Object temp = new Object(); // Need FIX: JSONArray.remove(int)
        ((org.codehaus.jettison.json.JSONArray)obj).put(index, temp);
        ((org.codehaus.jettison.json.JSONArray)obj).remove(temp);
      }
    }
    if( obj instanceof org.codehaus.jettison.json.JSONObject )
    {
      ((org.codehaus.jettison.json.JSONObject)obj).remove(String.valueOf(key));
    }
  }
  catch( org.codehaus.jettison.json.JSONException jsonException )
  {
    throw new IllegalStateException(jsonException);
  }
}

相关文章