本文整理汇总了Java中org.json.JSONException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java JSONException.getMessage方法的具体用法?Java JSONException.getMessage怎么用?Java JSONException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.json.JSONException
的用法示例。
在下文中一共展示了JSONException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LocationConfig
import org.json.JSONException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public LocationConfig(String jsonCountries) throws ConfigurationException {
if (jsonCountries == null || jsonCountries.isEmpty()) {
throw new ConfigurationException("Null or empty JSON string");
}
try {
JSONObject json = new JSONObject(jsonCountries);
Iterator<String> codes = json.keys();
while (codes.hasNext()) {
String key = codes.next();
cmap.put(key, json.getString(key));
}
} catch (JSONException e) {
throw new ConfigurationException(e.getMessage());
}
}
示例2: toJsonString
import org.json.JSONException; //导入方法依赖的package包/类
public String toJsonString() throws ConfigurationException {
String str = null;
if (cmap == null || cmap.isEmpty()) {
return null;
}
try {
JSONObject json = new JSONObject();
Iterator<String> it = cmap.keySet().iterator();
while (it.hasNext()) {
String code = it.next();
json.put(code, cmap.get(code));
}
str = json.toString();
} catch (JSONException e) {
throw new ConfigurationException(e.getMessage());
}
return str;
}
示例3: parse
import org.json.JSONException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void parse(String currencySpec) throws ConfigurationException {
if (currencySpec == null || currencySpec.isEmpty()) {
throw new ConfigurationException("Invalid currency specification");
}
try {
JSONObject json = new JSONObject(currencySpec);
Iterator<String> keys = json.keys();
while (keys.hasNext()) {
String code = keys.next();
String name = json.getString(code);
if (name != null && !name.isEmpty()) {
cmap.put(code, name);
reversemap.put(name, code);
}
}
} catch (JSONException e) {
throw new ConfigurationException(e.getMessage());
}
}
示例4: put
import org.json.JSONException; //导入方法依赖的package包/类
public GfJsonObject put(String key, Map<?, ?> value) throws GfJsonException {
try {
jsonObject.put(key, value);
} catch (JSONException e) {
throw new GfJsonException(e.getMessage());
}
return this;
}
示例5: toJSONString
import org.json.JSONException; //导入方法依赖的package包/类
/**
* Get the JSON String representation of this object
*/
public String toJSONString() throws ProtocolException {
String jsonString = null;
try {
if ("01".equals(this.version)) {
jsonString = toJSONObject01().toString();
} else {
throw new ProtocolException("Unsupported version: " + this.version);
}
} catch (JSONException e) {
throw new ProtocolException(e.getMessage());
}
return jsonString;
}
示例6: toJSONString
import org.json.JSONException; //导入方法依赖的package包/类
public String toJSONString() throws ProtocolException {
String jsonString = null;
try {
jsonString = toJSONObject().toString();
} catch (JSONException e) {
throw new ProtocolException(e.getMessage());
}
return jsonString;
}
示例7: getBody
import org.json.JSONException; //导入方法依赖的package包/类
@Override
public JSONObject getBody(String text) throws ServiceException {
try {
return new JsonObject(text);
}
catch (JSONException ex) {
throw new ServiceException(Status.BAD_REQUEST, ex.getMessage());
}
}
示例8: addJsonDefinitions
import org.json.JSONException; //导入方法依赖的package包/类
/**
* Loads and adds block definition from a JSON array string. These definitions will replace
* existing definitions, if the type names conflict.
*
* @param jsonString The InputStream containing the JSON block definitions.
*
* @return A count of definitions added.
* @throws IOException If there is a fundamental problem with the input.
* @throws BlockLoadingException If the definition is malformed.
*/
public int addJsonDefinitions(String jsonString) throws IOException, BlockLoadingException {
// Parse JSON first, avoiding side effects (partially added file) in the case of an error.
List<BlockDefinition> defs;
int arrayIndex = 0; // definition index
try {
JSONArray jsonArray = new JSONArray(jsonString);
defs = new ArrayList<>(jsonArray.length());
for (arrayIndex = 0; arrayIndex < jsonArray.length(); arrayIndex++) {
JSONObject jsonDef = jsonArray.getJSONObject(arrayIndex);
defs.add(new BlockDefinition(jsonDef));
}
} catch (JSONException e) {
String msg = "Block definition #" + arrayIndex + ": " + e.getMessage();
throw new BlockLoadingException(msg, e);
}
// Attempt to add each definition, catching redefinition errors.
int blockAddedCount = 0;
for (arrayIndex = 0; arrayIndex < defs.size(); ++arrayIndex) {
BlockDefinition def = defs.get(arrayIndex);
String typeName = def.getTypeName();
// Replace prior definition with warning, mimicking web behavior.
if (removeDefinition(typeName)) {
Log.w(TAG, "Block definition #" + arrayIndex +
" in JSON array replaces prior definition of \"" + typeName + "\".");
}
addDefinition(def);
blockAddedCount++;
}
return blockAddedCount;
}
示例9: toJson
import org.json.JSONException; //导入方法依赖的package包/类
public String toJson() throws ProtocolException {
String jsonString = null;
try {
jsonString = toJSONObject().toString();
// jsonString = gson.toJson(toJSONObject());
} catch (JSONException e) {
throw new ProtocolException(e.getMessage());
}
return jsonString;
}
示例10: b
import org.json.JSONException; //导入方法依赖的package包/类
public final JSONArray b() {
JSONArray jSONArray = new JSONArray();
try {
jSONArray.put(new JSONObject(toString()));
return jSONArray;
} catch (JSONException e) {
a.class.getSimpleName();
e.getMessage();
z.e();
return null;
}
}
示例11: SMSConfig
import org.json.JSONException; //导入方法依赖的package包/类
public SMSConfig(String jsonString) throws ConfigurationException {
try {
JSONObject jsonSMSConfig = new JSONObject(jsonString);
countryConfig = jsonSMSConfig.getJSONObject(COUNTRY_CONFIG);
providers = jsonSMSConfig.getJSONObject(PROVIDERS);
} catch (JSONException e) {
throw new ConfigurationException(e.getMessage());
}
}
示例12: toJSONString
import org.json.JSONException; //导入方法依赖的package包/类
/**
* Convert to JSON String
*/
public String toJSONString() throws ProtocolException {
String jsonString = null;
try {
jsonString = toJSONObject().toString();
} catch (JSONException e) {
throw new ProtocolException(e.getMessage());
}
return jsonString;
}
示例13: toJSONString
import org.json.JSONException; //导入方法依赖的package包/类
public String toJSONString() throws ProtocolException {
String jsonString = null;
try {
jsonString = toJSONObject().toString();
} catch (JSONException e) {
throw new ProtocolException(e.getMessage());
}
return jsonString;
}
示例14: Permissions
import org.json.JSONException; //导入方法依赖的package包/类
public Permissions(String jsonString) throws ConfigurationException {
try {
prsJson = new JSONObject(jsonString);
} catch (JSONException e) {
throw new ConfigurationException(e.getMessage());
}
}
示例15: putOnce
import org.json.JSONException; //导入方法依赖的package包/类
/**
*
* @param key
* @param value
* @return this GfJsonObject
* @throws GfJsonException if the key is a duplicate
*/
public GfJsonObject putOnce(String key, Object value) throws GfJsonException {
try {
jsonObject.putOnce(key, value);
} catch (JSONException e) {
throw new GfJsonException(e.getMessage());
}
return this;
}