本文整理了Java中org.json.JSONObject.getNumber()
方法的一些代码示例,展示了JSONObject.getNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.getNumber()
方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:getNumber
[英]Get the Number value associated with a key.
[中]
代码示例来源:origin: b3log/latke
/**
* Get the double value associated with a key.
*
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public double getDouble(String key) throws JSONException {
return this.getNumber(key).doubleValue();
}
代码示例来源:origin: b3log/latke
/**
* Get the long value associated with a key.
*
* @param key
* A key string.
* @return The long value.
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to a long.
*/
public long getLong(String key) throws JSONException {
return this.getNumber(key).longValue();
}
代码示例来源:origin: b3log/latke
/**
* Get the int value associated with a key.
*
* @param key
* A key string.
* @return The integer value.
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to an integer.
*/
public int getInt(String key) throws JSONException {
return this.getNumber(key).intValue();
}
代码示例来源:origin: b3log/latke
/**
* Get the float value associated with a key.
*
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public float getFloat(String key) throws JSONException {
return this.getNumber(key).floatValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the double value associated with a key.
*
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public double getDouble(String key) throws JSONException {
return this.getNumber(key).doubleValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the float value associated with a key.
*
* @param key
* A key string.
* @return The numeric value.
* @throws JSONException
* if the key is not found or if the value is not a Number
* object and cannot be converted to a number.
*/
public float getFloat(String key) throws JSONException {
return this.getNumber(key).floatValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the int value associated with a key.
*
* @param key
* A key string.
* @return The integer value.
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to an integer.
*/
public int getInt(String key) throws JSONException {
return this.getNumber(key).intValue();
}
代码示例来源:origin: org.b3log/latke
/**
* Get the long value associated with a key.
*
* @param key
* A key string.
* @return The long value.
* @throws JSONException
* if the key is not found or if the value cannot be converted
* to a long.
*/
public long getLong(String key) throws JSONException {
return this.getNumber(key).longValue();
}
代码示例来源:origin: raydac/netbeans-mmd-plugin
@Override
@Nullable
public MindMap doImport(@Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic actionTopic, @Nonnull @MustNotContainNull final Topic[] selectedTopics) throws Exception {
final File file = this.selectFileForExtension(panel, Texts.getString("MMDImporters.Mindmup2MindMap.openDialogTitle"), "mup", "Mindmup files (.MUP)", Texts.getString("MMDImporters.ApproveImport"));
if (file == null) {
return null;
}
final JSONObject parsedJson;
parsedJson = new JSONObject(FileUtils.readFileToString(file, "UTF-8"));
MindMap resultedMap = null;
final Number formatVersion = parsedJson.getNumber("formatVersion");
if (formatVersion == null) {
dialogProvider.msgError(null, Texts.getString("MMDImporters.Mindmup2MindMap.Error.WrongFormat"));
} else {
resultedMap = new MindMap(null, true);
resultedMap.setAttribute(MindMapPanel.ATTR_SHOW_JUMPS, "true");
final Topic mindMapRoot = Assertions.assertNotNull(resultedMap.getRoot());
final Map<Long, Topic> mapTopicId = new HashMap<Long, Topic>();
parseTopic(resultedMap, null, mindMapRoot, parsedJson, mapTopicId);
if (!mindMapRoot.getExtras().containsKey(Extra.ExtraType.FILE)) {
mindMapRoot.setExtra(new ExtraFile(new MMapURI(null, file, null)));
}
if (parsedJson.has("links")) {
final JSONArray links = parsedJson.getJSONArray("links");
processLinks(resultedMap, links, mapTopicId);
}
}
return resultedMap;
}
内容来源于网络,如有侵权,请联系作者删除!