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)
| 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 |
no test coverage detected