MCPcopy Create free account
hub / github.com/Trinea/android-common / getString

Method getString

src/cn/trinea/android/common/util/JSONUtils.java:267–280  ·  view source on GitHub ↗

get String from jsonObject @param jsonObject @param key @param defaultValue @return if jsonObject is null, return defaultValue if key is null or empty, return defaultValue if JSONObject#getString(String) exception, return defaultValue

(JSONObject jsonObject, String key, String defaultValue)

Source from the content-addressed store, hash-verified

265 * </ul>
266 */
267 public static String getString(JSONObject jsonObject, String key, String defaultValue) {
268 if (jsonObject == null || StringUtils.isEmpty(key)) {
269 return defaultValue;
270 }
271
272 try {
273 return jsonObject.getString(key);
274 } catch (JSONException e) {
275 if (isPrintException) {
276 e.printStackTrace();
277 }
278 return defaultValue;
279 }
280 }
281
282 /**
283 * get String from jsonData

Callers 9

getMapMethod · 0.95
parseKeyAndValueToMapMethod · 0.95
initDropDownStyleMethod · 0.45
initOnBottomStyleMethod · 0.45
cursorToHttpResponseMethod · 0.45
showMethod · 0.45
getStringArrayMethod · 0.45

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected