net.sf.json.JSON.isArray()方法的使用及代码示例

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

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

JSON.isArray介绍

暂无

代码示例

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

public static CreateRequest createRequest(AdminClient adminClient, TypeClient typeClient, ActionCreate actionCreate,
                     OA2Client client, JSON json) {
  if (json.isArray()) {
    throw new IllegalArgumentException("Error: cannot create a client from a JSON array -- it must be an map (JSON object) of key/value pairs");
  }
  return new CreateRequest(adminClient, client, (JSONObject) json);
}

代码示例来源:origin: OpenNMS/opennms

protected static JSONObject wrapArray(final JSON json) {
    if (json.isArray()) {
      final JSONObject wrapper = new JSONObject();
      wrapper.put("elements", json);
      return wrapper;

    } else {
      return (JSONObject) json;
    }
  }
}

代码示例来源:origin: woder/TorchBot

public UUID getUUIDName(String name){
  BiMap<String, UUID>invmap= names.inverse();
  UUID u = null;
  if(invmap.containsKey(name)){
    u = invmap.get(name);
  }else{
    String result = c.sendGetRequest("https://api.mojang.com/users/profiles/minecraft/" + name);
    JSON jsonr = JSONSerializer.toJSON(result);
    if(!jsonr.isArray()){
      JSONObject js = (JSONObject) jsonr;
      u = new UUID(new BigInteger(js.getString("id").substring(0, 16), 16).longValue(),new BigInteger(js.getString("id").substring(16), 16).longValue());               
      names.put(u, name);
    }
  }
  return u;
}

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

public static AttributeSetClientRequest createRequest(AdminClient aSubj,
                        TypeAttribute typeAttribute,
                        ActionSet actionSet,
                        OA2Client cTarget,
                        JSON content) {
  if (content.isArray()) {
    throw new GeneralException("Content must be a map of attributes to set");
  }
  return new AttributeSetClientRequest(aSubj, cTarget, (JSONObject) content);
}

代码示例来源:origin: org.opennms.protocols/org.opennms.protocols.xml

protected static JSONObject wrapArray(final JSON json) {
    if (json.isArray()) {
      final JSONObject wrapper = new JSONObject();
      wrapper.put("elements", json);
      return wrapper;

    } else {
      return (JSONObject) json;
    }
  }
}

代码示例来源:origin: com.cerner.ccl.comm/j4ccl-ssh

/**
 * Populate a fixed-length list from JSON data objects.
 *
 * @param sourceJson
 *            A {@link JSON} object representing an array of JSON data objects or a single JSON data object from
 *            which data will be pulled.
 * @param field
 *            A {@link Field} object representing the fixed-length list to be populated.
 * @param recordList
 *            A {@link RecordList} containing records into which values will be populated.
 */
private static void putFixedListFromJson(final JSON sourceJson, final Field field, final RecordList recordList) {
  if (sourceJson.isArray())
    putFixedListDeepFromJson((JSONArray) sourceJson, field, recordList);
  else
    putFixedListShallowFromJson((JSONObject) sourceJson, field, recordList);
}

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

public static AttributeRemoveRequest createRequest(AdminClient aSubj,
                          TypeAttribute typeAttribute,
                          ActionRemove actionRemove,
                          OA2Client cTarget,
                          JSON content) {
  //JSON content = SATFactory.getContent(json);
  if (!content.isArray()) {
    throw new GeneralException("Content must be a list of attributes to get");
  }
  JSONArray array = (JSONArray) content;
  String[] arrayString = (String[]) array.toArray(new String[array.size()]);
  return new AttributeRemoveRequest(aSubj, cTarget, Arrays.asList(arrayString));
}

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

@Override
protected void doIt(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Throwable {
  BufferedReader br = httpServletRequest.getReader();
  DebugUtil.dbg(this, "query=" + httpServletRequest.getQueryString());
  StringBuffer stringBuffer = new StringBuffer();
  String line = br.readLine();
  DebugUtil.dbg(this, "line=" + line);
  while (line != null) {
    stringBuffer.append(line);
    line = br.readLine();
  }
  br.close();
  if (stringBuffer.length() == 0) {
    throw new IllegalArgumentException("Error: There is no content for this request");
  }
  JSON rawJSON = JSONSerializer.toJSON(stringBuffer.toString());
  System.err.println(rawJSON.toString());
  if (rawJSON.isArray()) {
    getMyLogger().info("Error: Got a JSON array rather than a request:" + rawJSON);
    throw new IllegalArgumentException("Error: incorrect argument. Not a valid JSON request");
  }
  try {
    Response response = getClientManager().process((JSONObject) rawJSON);
    getResponseSerializer().serialize(response, httpServletResponse);
  } catch (Throwable t) {
    t.printStackTrace();
    throw t;
  }
}

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

public static AttributeGetRequest createRequest(AdminClient aSubj,
                        TypeAttribute typeAttribute,
                        ActionGet actionGet,
                        OA2Client cTarget,
                        JSON content) {
  //JSON content = SATFactory.getContent(json);
  if (!content.isArray()) {
    throw new GeneralException("Content must be a list of attributes to get");
  }
  JSONArray array = (JSONArray) content;
  String[] arrayString = (String[]) array.toArray(new String[array.size()]);
  return new AttributeGetRequest(aSubj, cTarget, Arrays.asList(arrayString));
}

代码示例来源:origin: jenkinsci/coverity-plugin

private JSONObject getJSONClassObject(JSONObject o, String targetClass) {
  //try old-style json format
  JSONObject jsonA = o.getJSONObject(getJsonSafeClassName());
  if(jsonA == null || jsonA.toString().equals("null")) {
    //new style json format
    JSON jsonB = (JSON) o.get("publisher");
    if(jsonB.isArray()) {
      JSONArray arr = (JSONArray) jsonB;
      for(Object i : arr) {
        JSONObject ji = (JSONObject) i;
        if(targetClass.equals(ji.get("stapler-class"))) {
          return ji;
        }
      }
    } else {
      return (JSONObject) jsonB;
    }
  } else {
    return jsonA;
  }
  return null;
}

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

if (!temp.isArray()) {
  ldap = (JSONObject) temp;
} else {

相关文章

微信公众号

最新文章

更多