當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.keySet方法代碼示例

本文整理匯總了Java中org.json.JSONObject.keySet方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.keySet方法的具體用法?Java JSONObject.keySet怎麽用?Java JSONObject.keySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.keySet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSame

import org.json.JSONObject; //導入方法依賴的package包/類
public boolean isSame(JSONObject o) {
    if (o == null) {
        return false;
    }
    boolean same = true;
    for (String key : o.keySet()) {
        same = false;
        for (FieldEntity field : fields) {
            if (field.getKey().equals(key)) {
                if (field.isSameType(o.get(key))) {
                    same = true;
                }
                break;
            }
        }
        if (!same) {
            break;
        }
    }
    return same;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:ClassEntity.java

示例2: toIssue

import org.json.JSONObject; //導入方法依賴的package包/類
/**
 * Returns the parsed issue, never null
 */
public static Issue toIssue(WebService webService, JSONObject json) {
    String key = json.optString("key");
    if (key == null || key.isEmpty()) {
        throw new IllegalArgumentException("Invalid Json, missing key: " + json);
    }
    Issue issue = webService.getIssue(key, EMPTY_REQUEST);
    JSONObject fields = json.optJSONObject("fields");
    if (fields != null) {
        FieldMap fieldMap = issue.getFieldMap();
        for (String id : fields.keySet()) {
            Object val = fields.get(id);
            if (val == JSONObject.NULL) {
                val = null;
            }
            Field field = fieldMap.getFieldById(id);
            if (field == null) {
                field = new Field(issue, id, new Value(val));
                fieldMap.addField(field);
            } else if (!Objects.equals(val, field.getValue().get())) {
                field.getValue().set(val);
            }
        }
    }
    return issue;
}
 
開發者ID:pascalgn,項目名稱:jiracli,代碼行數:29,代碼來源:ConversionUtils.java

示例3: unify

import org.json.JSONObject; //導入方法依賴的package包/類
/**
 * Unification applies a piece of memory within the current argument to a statement
 * which creates an instantiated statement
 * @param statement
 * @return the instantiated statement with elements of the argument applied as much as possible
 */
public String unify(String statement) {
    if (statement.indexOf('$') < 0) return statement;
    JSONArray table = this.getData();
    if (table != null && table.length() > 0) {
        for (int rownum = 0; rownum < table.length(); rownum++) {
            JSONObject row = table.getJSONObject(rownum);
            for (String key: row.keySet()) {
                int i;
                while ((i = statement.indexOf("$" + key + "$")) >= 0) {
                    statement = statement.substring(0, i) + row.get(key).toString() + statement.substring(i + key.length() + 2);
                }
                if (statement.indexOf('$') < 0) break;
            }
            if (statement.indexOf('$') < 0) break;
        }
    }
    return statement;
}
 
開發者ID:yacy,項目名稱:yacy_grid_mcp,代碼行數:25,代碼來源:SusiThought.java

示例4: getTimerMap

import org.json.JSONObject; //導入方法依賴的package包/類
/**
 * parses the JSON into a timer map.
 *
 * @param timersJson
 *            the timers JSON configuration.
 * @return the timer data in a map.
 */
public static Map<String, TimerData> getTimerMap(final JSONObject timersJson) {
	final Map<String, TimerData> timersMap = new TreeMap<>();
	for (final String timerType : timersJson.keySet()) {
		final JSONObject timerTypeJson = timersJson.getJSONObject(timerType);
		for (final String key : timerTypeJson.keySet()) {
			final JSONObject timerJson = timerTypeJson.getJSONObject(key);
			final String timersMapKey = getTimerKey(timerType, key);
			final TimerData timerData = new TimerData(timersMapKey, timerJson);
			timersMap.put(timersMapKey, timerData);

			if (timerJson.has(RESPONSE_COMMAND)) {
				final String responseCommand = timerJson.getString(RESPONSE_COMMAND);
				timersMap.put(getResponseCommandKey(responseCommand), timerData);
			}
		}
	}
	return timersMap;
}
 
開發者ID:coranos,項目名稱:neo-java,代碼行數:26,代碼來源:TimerUtil.java

示例5: createCompositeMapping

import org.json.JSONObject; //導入方法依賴的package包/類
public JSONObject createCompositeMapping(String compositeName) throws IOException {
	
	ResourcesScanner resourceScanner = new ResourcesScanner();
	
	Reflections reflections = new Reflections(resourceScanner);
	
	Set<String> resources = reflections.getResources(Pattern.compile(".*\\.mapping\\.json"));
	
	JSONObject properties = new JSONObject();
	
	for(String resource : resources) {
		InputStream is = getClass().getClassLoader().getResourceAsStream(resource);
		if(is == null) {
			throw new RuntimeException("Unable to read resource " + resource);
		}
		String json = IOUtils.toString(is, StandardCharsets.UTF_8);
		
		JSONObject part = new JSONObject(json);
		
		for(String key : part.keySet()) {
			properties.put(key, part.get(key));
		}
	}
	
	return new JSONObject().put("mappings", new JSONObject().put(compositeName, new JSONObject().put("properties", properties)));
}
 
開發者ID:skjolber,項目名稱:json-log-domain,代碼行數:27,代碼來源:MappingsGenerator.java

示例6: verifyReceivedMessages

import org.json.JSONObject; //導入方法依賴的package包/類
private void verifyReceivedMessages(JSONObject telemetry) {
    JSONArray receivedMessages = telemetry.getJSONArray(RECEIVED_MESSAGES);
    for (Object obj : receivedMessages) {
        JSONObject receivedMessage = (JSONObject) obj;
        Set<String> keys = receivedMessage.keySet();
        assertEquals(1, keys.size());
        String key = keys.iterator().next();
        if (SPEECH_HYPOTHESIS.equalsIgnoreCase(key)) {
            JSONArray values = receivedMessage.getJSONArray(key);
            assertNotNull(values);
            assertEquals(2, values.length());
        } else {
            String value = receivedMessage.getString(key);
            assertNotNull(value);
        }
    }
}
 
開發者ID:CatalystCode,項目名稱:SpeechToText-WebSockets-Java,代碼行數:18,代碼來源:TelemetryInfoTest.java

示例7: getSorted

import org.json.JSONObject; //導入方法依賴的package包/類
public static JSONObject getSorted(final JSONObject obj) {
	final JSONObject json = new JSONObject();
	try {
		final Field map = json.getClass().getDeclaredField("map");
		map.setAccessible(true);
		map.set(json, new TreeMap<>());
		map.setAccessible(false);
	} catch (final Exception e) {
		throw new RuntimeException(e);
	}

	for (final String key : obj.keySet()) {
		json.put(key, obj.get(key));
	}

	return json;
}
 
開發者ID:coranos,項目名稱:neo-java,代碼行數:18,代碼來源:TestUtil.java

示例8: putvaluesfromlist

import org.json.JSONObject; //導入方法依賴的package包/類
public static void putvaluesfromlist(String gender, JSONArray list) {
    if (list != null) {
        HashMap<IGuild, List<IRole>> serverrolesmap = new HashMap<>();
        for (int i = 0; i < list.length(); i++) {
            JSONObject serverroles = Utils.objectToJSONObject(list.get(i));
            if (serverroles != null) {
                for (Object serverid : serverroles.keySet()) {
                    JSONArray array = Utils.objectToJSONArray(serverroles.get(serverid.toString()));
                    ArrayList<IRole> roles = new ArrayList<>();
                    for (int j = 0; j < array.length(); j++) {
                        roles.add(INIT.BOT.getRoleByID(Long.valueOf(array.getString(i))));
                    }
                    serverrolesmap.put(INIT.BOT.getGuildByID(Long.valueOf(serverid.toString())), roles);
                }
            }

        }
        gendersave.put(gender, serverrolesmap);
    }
}
 
開發者ID:ModdyLP,項目名稱:MoMuOSB,代碼行數:21,代碼來源:RoleManagement.java

示例9: getEditableFields

import org.json.JSONObject; //導入方法依賴的package包/類
@Override
public Collection<Field> getEditableFields(Issue issue) {
    JSONObject response = get("/rest/api/latest/issue/" + issue.getKey() + "/editmeta", TO_OBJECT);
    JSONObject json = response.getJSONObject("fields");
    List<Field> editableFields = new ArrayList<>();
    for (String id : json.keySet()) {
        Field field = issue.getFieldMap().getFieldById(id);
        if (field == null) {
            LOGGER.debug("Unknown field in editmeta: {} (issue {})", id, issue);
        } else {
            boolean setAllowed = false;
            JSONObject editMeta = json.getJSONObject(id);
            JSONArray operations = editMeta.optJSONArray("operations");
            if (operations != null) {
                for (Object obj : operations) {
                    if ("set".equals(obj)) {
                        setAllowed = true;
                        break;
                    }
                }
            }
            if (setAllowed && !editableFields.contains(field)) {
                editableFields.add(field);
            }
        }
    }
    Collections.sort(editableFields, new FieldComparator());
    return editableFields;
}
 
開發者ID:pascalgn,項目名稱:jiracli,代碼行數:30,代碼來源:DefaultWebService.java

示例10: getObservations

import org.json.JSONObject; //導入方法依賴的package包/類
public List<String> getObservations(String featureName) {
    List<String> list = new ArrayList<>();
    JSONArray table = this.getData();
    if (table != null && table.length() > 0) {
        for (int rc = 0; rc < table.length(); rc++) {
        JSONObject row = table.getJSONObject(rc);
            for (String key: row.keySet()) {
                if (key.equals(featureName)) list.add(row.get(key).toString());
            }
        }
    }
    return list;
}
 
開發者ID:yacy,項目名稱:yacy_grid_mcp,代碼行數:14,代碼來源:SusiThought.java

示例11: loadUsers

import org.json.JSONObject; //導入方法依賴的package包/類
private void loadUsers() {
	JSONObject guildObj = Database.opt(guild.getStringID());
	if(guildObj == null) {
		return;
	}

	JSONObject usersObj = guildObj.optJSONObject(USERS_KEY);
	if(usersObj != null) {
		for(String userKey : usersObj.keySet()) {
			long userID = Long.parseLong(userKey);
			usersMap.put(userID, new DBUser(guild, userID));
		}
	}
}
 
開發者ID:Shadorc,項目名稱:Shadbot,代碼行數:15,代碼來源:DBGuild.java

示例12: isPremium

import org.json.JSONObject; //導入方法依賴的package包/類
public static boolean isPremium(IGuild guild) {
	JSONObject donatorsObj = premiumObj.getJSONObject(DONATORS);
	for(String userKey : donatorsObj.keySet()) {
		JSONArray keysArray = donatorsObj.getJSONArray(userKey);
		for(int i = 0; i < keysArray.length(); i++) {
			Relic relic = new Relic(keysArray.getJSONObject(i));
			if(PremiumManager.isValid(relic, RelicType.GUILD) && relic.getGuildID() == guild.getLongID()) {
				return true;
			}
		}
	}

	return false;
}
 
開發者ID:Shadorc,項目名稱:Shadbot,代碼行數:15,代碼來源:PremiumManager.java

示例13: toFields

import org.json.JSONObject; //導入方法依賴的package包/類
private static List<Field> toFields(Issue issue, JSONObject json) {
    List<Field> fields = new ArrayList<>();
    for (String id : json.keySet()) {
        Object val = json.get(id);
        if (val == JSONObject.NULL) {
            val = null;
        }
        fields.add(new Field(issue, id, new Value(val)));
    }
    return fields;
}
 
開發者ID:pascalgn,項目名稱:jiracli,代碼行數:12,代碼來源:DefaultWebService.java

示例14: collectGenerateFiled

import org.json.JSONObject; //導入方法依賴的package包/類
private List<String> collectGenerateFiled(JSONObject json) {
    Set<String> keySet = json.keySet();
    List<String> fieldList = new ArrayList<String>();
    for (String key : keySet) {
        if (!existDeclareField(key, json)) {
            fieldList.add(key);
        }
    }
    return fieldList;
}
 
開發者ID:zeng198821,項目名稱:CodeGenerate,代碼行數:11,代碼來源:ConvertBridge.java

示例15: migrateIPS

import org.json.JSONObject; //導入方法依賴的package包/類
protected void migrateIPS(File oldFile, File newFile) {
    try {
        StringBuilder fileData = new StringBuilder();
        BufferedReader reader = new BufferedReader(new FileReader(oldFile));

        String line;

        while ((line = reader.readLine()) != null)
            fileData.append(line);

        JSONObject object = new JSONObject(fileData.toString());

        BufferedWriter writer = new BufferedWriter(new FileWriter(newFile));

        for (String key : object.keySet()) {
            JSONArray array = object.getJSONArray(key);

            for (int i = 0; i < array.length(); i++) {
                String ipEntry = array.getString(i);

                writer.write(key + ":" + ipEntry + "\n");
            }
        }

        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:shawlaf,項目名稱:Banmanager,代碼行數:30,代碼來源:ConfigurationManager.java


注:本文中的org.json.JSONObject.keySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。