Package org.json.simple

Examples of org.json.simple.JSONArray


   * <code>SCHEME://HOST:PORT</code> in the file status.
   * @return The JSON representation of the file status array.
   */
  @SuppressWarnings("unchecked")
  public static JSONArray fileStatusToJSON(FileStatus[] status, String hoopBaseUrl) {
    JSONArray json = new JSONArray();
    if (status != null) {
      for (FileStatus s : status) {
        json.add(fileStatusToJSON(s, hoopBaseUrl));
      }
    }
    return json;
  }
View Full Code Here


        response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case LIST: {
        FSListStatus command = new FSListStatus(path.value(), filter.value());
        JSONArray json = fsExecute(user, doAs.value(), command);
        if (filter.value() == null) {
          AUDIT_LOG.info("[{}]", path);
        }
        else {
          AUDIT_LOG.info("[{}] filter [{}]", path, filter.value());
View Full Code Here

  public FileStatus[] listStatus(Path f) throws IOException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("op", "list");
    HttpURLConnection conn = getConnection("GET", params, f);
    validateResponse(conn, HttpURLConnection.HTTP_OK);
    JSONArray json = (JSONArray) jsonParse(conn);
    FileStatus[] array = new FileStatus[json.size()];
    for (int i = 0; i < json.size(); i++) {
      array[i] = createFileStatus((JSONObject) json.get(i));
    }
    return array;
  }
View Full Code Here

   * @param certs Certificates to encode.
   * @return A JSON object with one field, "chain", holding a JSON array of base64-encoded certs.
   */
  @SuppressWarnings("unchecked") // Because JSONObject, JSONArray extend raw types.
  JSONObject encodeCertificates(List<Certificate> certs) {
    JSONArray retObject = new JSONArray();

    try {
      for (Certificate cert : certs) {
        retObject.add(Base64.encodeBase64String(cert.getEncoded()));
      }
    } catch (CertificateEncodingException e) {
      throw new CertificateTransparencyException("Error encoding certificate", e);
    }

View Full Code Here

    List<NameValuePair> params = createParamsList("leaf_index", "tree_size",
      Long.toString(leafindex), Long.toString(treeSize));

    String response = postInvoker.makeGetRequest(logUrl + GET_ENTRY_AND_PROOF, params);
    JSONObject entry = (JSONObject) JSONValue.parse(response);
    JSONArray auditPath = (JSONArray) entry.get("audit_path");

    return Deserializer.parseLogEntryWithProof(jsonToLogEntry.apply(entry), auditPath, leafindex,
      treeSize);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<ParsedLogEntry> parseLogEntries(String response) {
    Preconditions.checkNotNull(response, "Log entries response from Log should not be null.");

    JSONObject responseJson = (JSONObject) JSONValue.parse(response);
    JSONArray arr = (JSONArray) responseJson.get("entries");
    return Lists.transform(arr, jsonToLogEntry);
  }
View Full Code Here

   */
  private List<ByteString> parseConsistencyProof(String response) {
    Preconditions.checkNotNull(response, "Merkle Consistency response should not be null.");

    JSONObject responseJson = (JSONObject) JSONValue.parse(response);
    JSONArray arr = (JSONArray) responseJson.get("consistency");

    List<ByteString> proof = new ArrayList<ByteString>();
    for(Object node: arr) {
      proof.add(ByteString.copyFrom(Base64.decodeBase64((String) node)));
    }
View Full Code Here

   */
  List<Certificate> parseRootCertsResponse(String response) {
    List<Certificate> certs = new ArrayList<>();

    JSONObject entries = (JSONObject) JSONValue.parse(response);
    JSONArray entriesArray = (JSONArray) entries.get("certificates");

    for(Object i: entriesArray) {
      // We happen to know that JSONArray contains strings.
      byte[] in = Base64.decodeBase64((String) i);
      try {
View Full Code Here

            conn.setDoOutput(true);

            final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            final String response = reader.readLine();

            final JSONArray array = (JSONArray) JSONValue.parse(response);

            if (array.size() == 0) {
                this.plugin.getLogger().warning("The updater could not find any files for the project id " + this.id);
                this.result = UpdateResult.FAIL_BADID;
                return false;
            }

            this.versionName = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.TITLE_VALUE);
            this.versionLink = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.LINK_VALUE);
            this.versionType = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.TYPE_VALUE);
            this.versionGameVersion = (String) ((JSONObject) array.get(array.size() - 1)).get(Updater.VERSION_VALUE);

            return true;
        } catch (final IOException e) {
            if (e.getMessage().contains("HTTP response code: 403")) {
                this.plugin.getLogger().warning("dev.bukkit.org rejected the API key provided in plugins/Updater/config.yml");
View Full Code Here

      
      System.out.println("########################");
      System.out.println("Search the persons that have name  JOHN");
      Object obj = JSONValue.parse( ApiAuthRest.getRequestGet("person?q=john"));
       JSONObject jsonObject = (JSONObject) obj;
       JSONArray arrayResult = (JSONArray) jsonObject.get("results");
       /*
        * Leemo primera posicion
        */
       System.out.println("########################");
       int largoArray = arrayResult.size();
       int contador;
       for(contador=0; contador < largoArray; contador ++){
         JSONObject registro = (JSONObject) arrayResult.get(contador);
         String uuid = (String) registro.get("uuid");
         String display = (String) registro.get("display");
         System.out.println("Rows "+ contador + " => Result Persons UUID:" + uuid +" Display:"+display);
        
         //Show ROWS LINKS
         JSONArray arrayResultLinks = (JSONArrayregistro.get("links");
         int largoArrayLinks = arrayResultLinks.size();
           int contadorLinks;
          for(contadorLinks=0; contadorLinks < largoArrayLinks; contadorLinks ++){
            JSONObject registroLink = (JSONObject) arrayResultLinks.get(contadorLinks);
             String uri = (String) registroLink.get("uri");
             String rel = (String) registroLink.get("rel");
             System.out.println("==>Record Row "+ contador + "."+ contadorLinks
                   +" =>  URI:" + uri +" REL:"+rel);
                       
View Full Code Here

TOP

Related Classes of org.json.simple.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.