当前位置: 首页>>代码示例>>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;未经允许,请勿转载。