org.json.JSONException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.json.JSONException.getMessage()方法的一些代码示例,展示了JSONException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONException.getMessage()方法的具体详情如下:
包路径:org.json.JSONException
类名称:JSONException
方法名:getMessage

JSONException.getMessage介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JSONObject jsonObj = null;
try {
  jsonObj = XML.toJSONObject(sampleXml);
} catch (JSONException e) {
  Log.e("JSON exception", e.getMessage());
  e.printStackTrace();
} 

Log.d("XML", sampleXml);

Log.d("JSON", jsonObj.toString());

代码示例来源:origin: Netflix/zuul

public Object get(String key) {
  if(!this.has(key)) {
    return null;
  }
  try {
    return this.json.get(key);
  } catch (JSONException e) {
    LOG.debug(e.getMessage(),e);
    return null;
  }
}

代码示例来源:origin: apache/geode

/**
 *
 * @param source A string beginning with { (left brace) and ending with } (right brace).
 * @throws GfJsonException - If there is a syntax error in the source string or a duplicated key.
 */
public GfJsonObject(String source) throws GfJsonException {
 try {
  this.jsonObject = new JSONObject(source);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
}

代码示例来源:origin: apache/geode

public GfJsonObject put(String key, Map<?, ?> value) throws GfJsonException {
 try {
  jsonObject.put(key, value);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: apache/geode

/**
 *
 * @return this GfJsonObject
 * @throws GfJsonException If the object contains an invalid number.
 */
public String toIndentedString(int indentFactor) throws GfJsonException {
 try {
  return jsonObject.toString(indentFactor);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
}

代码示例来源:origin: apache/geode

/**
 * @return this GfJsonArray
 * @throws GfJsonException If the index is negative or if the value is not finite.
 */
public GfJsonArray put(int index, Collection<?> value) throws GfJsonException {
 try {
  this.jsonArray.put(index, value);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: apache/geode

/**
 * @return this GfJsonArray
 * @throws GfJsonException If the index is negative or if the the value is an invalid number.
 */
public GfJsonArray put(int index, Map<?, ?> value) throws GfJsonException {
 try {
  this.jsonArray.put(index, value);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: apache/geode

/**
 * Get the object value associated with an index.
 *
 * @return An object value.
 * @throws GfJsonException If there is no value for the index.
 */
public Object get(int index) throws GfJsonException {
 try {
  return this.jsonArray.get(index);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
}

代码示例来源:origin: facebook/facebook-android-sdk

protected String getClientState(String authId) {
  JSONObject param = new JSONObject();
  try {
    param.put(LoginLogger.EVENT_PARAM_AUTH_LOGGER_ID, authId);
    param.put(LoginLogger.EVENT_PARAM_METHOD, getNameForLogging());
    putChallengeParam(param);
  } catch (JSONException e) {
    Log.w("LoginMethodHandler", "Error creating client state json: " + e.getMessage());
  }
  return param.toString();
}

代码示例来源:origin: apache/geode

/**
 * @return this GfJsonArray
 * @throws GfJsonException If the index is negative or if the the value is an invalid number.
 */
public GfJsonArray put(int index, Object value) throws GfJsonException {
 try {
  this.jsonArray.put(index, extractInternalForGfJsonOrReturnSame(value));
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: apache/geode

public GfJsonObject getJSONObject(int index) throws GfJsonException {
 try {
  return new GfJsonObject(jsonArray.getJSONObject(index));
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
}

代码示例来源:origin: Netflix/zuul

public Object get(String key) {
  if(!this.has(key)) {
    return null;
  }
  try {
    return this.json.get(key);
  } catch (JSONException e) {
    LOG.debug(e.getMessage(),e);
    return null;
  }
}

代码示例来源:origin: apache/geode

/**
 *
 * @return this GfJsonObject
 * @throws GfJsonException If the value is a non-finite number.
 */
public GfJsonObject put(String key, Collection<?> value) throws GfJsonException {
 try {
  jsonObject.putOpt(key, value);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
public void onSuccess(JSONObject userInfo) {
  try {
    String userId = userInfo.getString("id");
    result.putString(NativeProtocol.EXTRA_USER_ID, userId);
    onComplete(request, result);
  } catch (JSONException ex) {
    loginClient.complete(LoginClient.Result.createErrorResult(
        loginClient.getPendingRequest(),
        "Caught exception",
        ex.getMessage()));
  }
}

代码示例来源:origin: apache/geode

public GfJsonObject putJSONArray(String key, GfJsonArray value) throws GfJsonException {
 try {
  jsonObject.putOpt(key, value.getInternalJsonArray());
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: facebook/facebook-android-sdk

private static Bundle create(
  ShareMessengerOpenGraphMusicTemplateContent openGraphMusicTemplateContent,
  boolean dataErrorsFatal) {
  Bundle params = createBaseParameters(openGraphMusicTemplateContent, dataErrorsFatal);
  try {
    MessengerShareContentUtility.addOpenGraphMusicTemplateContent(
      params,
      openGraphMusicTemplateContent);
  } catch (JSONException e) {
    throw new FacebookException(
      "Unable to create a JSON Object from the provided " +
        "ShareMessengerOpenGraphMusicTemplateContent: " + e.getMessage());
  }
  return params;
}

代码示例来源:origin: facebook/facebook-android-sdk

private static Bundle create(
  ShareMessengerMediaTemplateContent mediaTemplateContent,
  boolean dataErrorsFatal) {
  Bundle params = createBaseParameters(mediaTemplateContent, dataErrorsFatal);
  try {
    MessengerShareContentUtility.addMediaTemplateContent(
      params,
      mediaTemplateContent);
  } catch (JSONException e) {
    throw new FacebookException(
      "Unable to create a JSON Object from the provided " +
        "ShareMessengerMediaTemplateContent: " + e.getMessage());
  }
  return params;
}

代码示例来源:origin: facebook/facebook-android-sdk

private static Bundle create(
  ShareMessengerGenericTemplateContent genericTemplateContent,
  boolean dataErrorsFatal) {
  Bundle params = createBaseParameters(genericTemplateContent, dataErrorsFatal);
  try {
    MessengerShareContentUtility.addGenericTemplateContent(
      params,
      genericTemplateContent);
  } catch (JSONException e) {
    throw new FacebookException(
      "Unable to create a JSON Object from the provided " +
        "ShareMessengerGenericTemplateContent: " + e.getMessage());
  }
  return params;
}

代码示例来源:origin: apache/geode

public GfJsonObject putAsJSONObject(String key, Object value) throws GfJsonException {
 try {
  Object internalJsonObj = extractInternalForGfJsonOrReturnSame(value);
  if (internalJsonObj == value) {
   GfJsonObject jsonObj = new GfJsonObject(value);
   internalJsonObj = jsonObj.getInternalJsonObject();
  }
  jsonObject.put(key, internalJsonObj);
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

代码示例来源:origin: apache/geode

/**
 *
 * @return this GfJsonObject
 * @throws GfJsonException If the value is a non-finite number.
 */
public GfJsonObject putOpt(String key, Object value) throws GfJsonException {
 try {
  jsonObject.putOpt(key, extractInternalForGfJsonOrReturnSame(value));
 } catch (JSONException e) {
  throw new GfJsonException(e.getMessage());
 }
 return this;
}

相关文章