本文整理了Java中org.json.simple.JSONObject.clear()
方法的一些代码示例,展示了JSONObject.clear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.clear()
方法的具体详情如下:
包路径:org.json.simple.JSONObject
类名称:JSONObject
方法名:clear
暂无
代码示例来源:origin: xXKeyleXx/MyPet
@Override
public void onDisable() {
save();
version = 0;
calculator = null;
expMap.clear();
intervalMap.clear();
}
代码示例来源:origin: xXKeyleXx/MyPet
protected void load() {
try (InputStreamReader reader = new InputStreamReader(new GZIPInputStream(new FileInputStream(cacheFile)), StandardCharsets.UTF_8)) {
JSONParser parser = new JSONParser();
Object obj = parser.parse(reader);
if (obj instanceof JSONObject) {
JSONObject cacheObject = (JSONObject) obj;
this.expMap = (JSONObject) cacheObject.get("expMap");
this.version = (long) cacheObject.get("version");
this.calculator = cacheObject.get("calculator").toString();
loadIntervals();
}
} catch (Throwable e) {
cacheFile.delete();
version = 0;
calculator = null;
expMap.clear();
intervalMap.clear();
}
}
代码示例来源:origin: xXKeyleXx/MyPet
public void checkVersion(ExperienceCalculator calculator) {
long version = calculator.getVersion();
String identifier = calculator.getIdentifier();
if (version != this.version || !identifier.equals(this.calculator)) {
expMap.clear();
this.version = version;
this.calculator = identifier;
MyPetApi.getLogger().info("Current Exp-Cache is invalid, it will be recalculated.");
save();
}
}
代码示例来源:origin: com.twitter.elephantbird/elephant-bird-pig
/**
* The first element is expected to be a map, or null. Anything else causes an error.
* @param tuple the tuple to write.
*/
@Override
@SuppressWarnings("unchecked")
public void putNext(Tuple tuple) throws IOException {
json.clear();
if (tuple != null && tuple.size() >= 1) {
Map<String, Object> map = (Map<String, Object>) tuple.get(0);
if (keysToKeep_ == null) {
json.putAll(map);
} else {
for (Map.Entry<String, Object> entry : map.entrySet()) {
if (keysToKeep_.contains(entry.getKey())) {
json.put(entry.getKey(), entry.getValue());
}
}
}
}
try {
writer.write(null, new Text(json.toString()));
} catch (InterruptedException e) {
// Under what circumstances does this happen?
throw new IOException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!