Java Code Examples for org.json.simple.JSONArray#forEach()

The following examples show how to use org.json.simple.JSONArray#forEach() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Mojang.java    From java-mojang-api with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves all the username a certain UUID has had in the past, including the current one.
 *
 * @param uuid the UUID
 *
 * @return a map with the username as key value and the Timestamp as a {@link java.lang.Long Long}
 */
public Map<String, Long> getNameHistoryOfPlayer(String uuid)
{
    JSONArray         arr     = getJSONArray("https://api.mojang.com/user/profiles/" + uuid + "/names");
    Map<String, Long> history = new HashMap<>();
    arr.forEach(o ->
    {
        JSONObject obj = (JSONObject) o;
        history.put((String) obj.get("name"), obj.get("changedToAt") == null ? 0 : Long.parseLong(obj.get("changedToAt").toString()));
    });
    return history;
}
 
Example 2
Source File: EntryPoint.java    From daq with Apache License 2.0 4 votes vote down vote up
private static void addBacnetProperties(JSONArray bacnetObjectsList) {
    bacnetObjectsList.forEach(bacnetObject -> addProperty((JSONObject) bacnetObject));
}
 
Example 3
Source File: EntryPoint.java    From daq with Apache License 2.0 4 votes vote down vote up
private static void getDeviceID(JSONArray bacnetObjectsList) {
    bacnetObjectsList.forEach(bacnetObject -> getID((JSONObject) bacnetObject));
}
 
Example 4
Source File: Deserializer.java    From certificate-transparency-java with Apache License 2.0 3 votes vote down vote up
/**
 * Parses the audit proof retrieved from Log.
 *
 * @param proof An array of base64-encoded Merkle Tree nodes proving the inclusion of the chosen
 *     certificate.
 * @param leafIndex The index of the desired entry.
 * @param treeSize The tree size of the tree for which the proof is desired.
 * @return {@link MerkleAuditProof}
 */
public static MerkleAuditProof parseAuditProof(JSONArray proof, long leafIndex, long treeSize) {

  MerkleAuditProof audit_proof = new MerkleAuditProof(Ct.Version.V1, treeSize, leafIndex);
  proof.forEach(node -> audit_proof.pathNode.add(Base64.decodeBase64((String) node)));
  return audit_proof;
}