@Test public void testGetStringFromJSON() throws Exception { }
public static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue) { if(data == null) { return defaultValue; } try { final String value = (String) data.get(key); if (value != null) { return value; } return defaultValue; } catch (Exception e) { return defaultValue; } }
JSONHelper { public static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue) { if(data == null) { return defaultValue; } try { final String value = (String) data.get(key); if (value != null) { return value; } return defaultValue; } catch (Exception e) { return defaultValue; } } }
JSONHelper { public static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue) { if(data == null) { return defaultValue; } try { final String value = (String) data.get(key); if (value != null) { return value; } return defaultValue; } catch (Exception e) { return defaultValue; } }  }
JSONHelper { public static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue) { if(data == null) { return defaultValue; } try { final String value = (String) data.get(key); if (value != null) { return value; } return defaultValue; } catch (Exception e) { return defaultValue; } }  static final JSONObject createJSONObject(final String key, final String value); static final JSONObject createJSONObject(final String key, final Object value); static final JSONObject createJSONObject(final String key, final JSONObject value); static final JSONObject createJSONObject(final String key, final int value); static final JSONObject createJSONObject(final String key, final boolean value); static final JSONObject createJSONObject(final String key, final JSONArray value); static final JSONObject createJSONObject(final String content); static final JSONObject createJSONObject4Tokener(final JSONTokener content); static final JSONObject getJSONObject(final JSONObject content, String key); static final Object get(final JSONObject content, String key); static final JSONObject getJSONObject(final JSONArray content, int key); static final JSONArray getJSONArray(final JSONObject content, String key); static final Map<String, T> getObjectAsMap(final JSONObject obj); static final List<T> getArrayAsList(final JSONArray array); static JSONArray getEmptyIfNull(final JSONArray array); static boolean getBooleanFromJSON(final JSONObject data, final String key, final boolean defaultValue); static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue); static final String getStringFromJSON(final JSONObject data, final String defaultValue); static final String getStringFromJSON(final JSONArray data, final String defaultValue); static final boolean accumulateValue(final JSONObject json, final String key, final Object value); static final boolean putValue(final JSONObject json, final String key, final Object value); static final boolean put(final JSONObject json, final String key, final JSONArray value); static final Boolean putValue(final JSONObject json, final String key, final boolean value); static final boolean putValue(final JSONObject json, final String key, final long value); static final boolean putValue(final JSONObject json, final String key, final Date value); static final boolean putValue(final JSONObject json, final String key, final double value); static final boolean putAll(final JSONArray toArray, JSONArray fromArray); static JSONArray createJSONArray(final String content, boolean emptyIfNull); static JSONArray createJSONArray(final String content); static JSONArray createJSONArray(final Object content); static JSONArray createJSONArrayJsonKeys(final JSONObject json); static boolean isEqual(final JSONObject jsonObject1, final JSONObject jsonObject2); static boolean isEqual(JSONArray jsonArray1, JSONArray jsonArray2); static JSONObject merge(final JSONObject baseData, final JSONObject overrides); static String optString(JSONObject obj, String key); static String optString(JSONObject obj, String key, String defaultValue); static String getString(JSONObject obj, String key); }
JSONHelper { public static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue) { if(data == null) { return defaultValue; } try { final String value = (String) data.get(key); if (value != null) { return value; } return defaultValue; } catch (Exception e) { return defaultValue; } }  static final JSONObject createJSONObject(final String key, final String value); static final JSONObject createJSONObject(final String key, final Object value); static final JSONObject createJSONObject(final String key, final JSONObject value); static final JSONObject createJSONObject(final String key, final int value); static final JSONObject createJSONObject(final String key, final boolean value); static final JSONObject createJSONObject(final String key, final JSONArray value); static final JSONObject createJSONObject(final String content); static final JSONObject createJSONObject4Tokener(final JSONTokener content); static final JSONObject getJSONObject(final JSONObject content, String key); static final Object get(final JSONObject content, String key); static final JSONObject getJSONObject(final JSONArray content, int key); static final JSONArray getJSONArray(final JSONObject content, String key); static final Map<String, T> getObjectAsMap(final JSONObject obj); static final List<T> getArrayAsList(final JSONArray array); static JSONArray getEmptyIfNull(final JSONArray array); static boolean getBooleanFromJSON(final JSONObject data, final String key, final boolean defaultValue); static final String getStringFromJSON(final JSONObject data, final String key, final String defaultValue); static final String getStringFromJSON(final JSONObject data, final String defaultValue); static final String getStringFromJSON(final JSONArray data, final String defaultValue); static final boolean accumulateValue(final JSONObject json, final String key, final Object value); static final boolean putValue(final JSONObject json, final String key, final Object value); static final boolean put(final JSONObject json, final String key, final JSONArray value); static final Boolean putValue(final JSONObject json, final String key, final boolean value); static final boolean putValue(final JSONObject json, final String key, final long value); static final boolean putValue(final JSONObject json, final String key, final Date value); static final boolean putValue(final JSONObject json, final String key, final double value); static final boolean putAll(final JSONArray toArray, JSONArray fromArray); static JSONArray createJSONArray(final String content, boolean emptyIfNull); static JSONArray createJSONArray(final String content); static JSONArray createJSONArray(final Object content); static JSONArray createJSONArrayJsonKeys(final JSONObject json); static boolean isEqual(final JSONObject jsonObject1, final JSONObject jsonObject2); static boolean isEqual(JSONArray jsonArray1, JSONArray jsonArray2); static JSONObject merge(final JSONObject baseData, final JSONObject overrides); static String optString(JSONObject obj, String key); static String optString(JSONObject obj, String key, String defaultValue); static String getString(JSONObject obj, String key);  }