private String getStringSafe(JSONObject object, String key){ try { return object.getString(key); } catch (JSONException e) { return null; } }
/** * Get the string associated with a key. * * @param key * A key string. * @return A string which is the value. * @throws JSONException * if the key is not found. */ public String getString(Enum<?> key) throws JSONException { return getString(key.name()); }
/** * Get the string associated with a key. * * @param key * A key string. * @return A string which is the value. * @throws JSONException * if the key is not found. */ public String getString(Enum<?> key) throws JSONException { return getString(key.name()); }
public boolean isClassificationInProgressOnBranch(String branchPath) throws RestClientException, JSONException { final JSONObject classification = getLatestClassificationObjectOnBranch(branchPath); if (classification != null) { final String status = classification.getString("status"); return "SCHEDULED".equals(status) || "RUNNING".equals(status); } return false; }
StringBuffer sb = new StringBuffer(); if (o.has("Status-Code") && o.has("Reason-Phrase")) { sb.append(o.getString("HTTP-Version")); sb.append(' '); sb.append(o.getString("Status-Code")); sb.append(' '); sb.append(o.getString("Reason-Phrase")); } else if (o.has("Method") && o.has("Request-URI")) { sb.append(o.getString("Method")); sb.append(' '); sb.append('"'); sb.append(o.getString("Request-URI")); sb.append('"'); sb.append(' '); sb.append(o.getString("HTTP-Version")); } else { throw new JSONException("Not enough material for an HTTP header."); sb.append(s); sb.append(": "); sb.append(o.getString(s)); sb.append(CRLF);
StringBuffer sb = new StringBuffer(); if (o.has("Status-Code") && o.has("Reason-Phrase")) { sb.append(o.getString("HTTP-Version")); sb.append(' '); sb.append(o.getString("Status-Code")); sb.append(' '); sb.append(o.getString("Reason-Phrase")); } else if (o.has("Method") && o.has("Request-URI")) { sb.append(o.getString("Method")); sb.append(' '); sb.append('"'); sb.append(o.getString("Request-URI")); sb.append('"'); sb.append(' '); sb.append(o.getString("HTTP-Version")); } else { throw new JSONException("Not enough material for an HTTP header."); sb.append(s); sb.append(": "); sb.append(o.getString(s)); sb.append(CRLF);
/** * Convert a JSONObject into a cookie list. A cookie list is a sequence * of name/value pairs. The names are separated from the values by '='. * The pairs are separated by ';'. The characters '%', '+', '=', and ';' * in the names and values are replaced by "%hh". * @param o A JSONObject * @return A cookie list string * @throws JSONException */ public static String toString(JSONObject o) throws JSONException { boolean b = false; Iterator<?> keys = o.keys(); String s; StringBuffer sb = new StringBuffer(); while (keys.hasNext()) { s = keys.next().toString(); if (!o.isNull(s)) { if (b) { sb.append(';'); } sb.append(Cookie.escape(s)); sb.append("="); sb.append(Cookie.escape(o.getString(s))); b = true; } } return sb.toString(); } }
/** * Convert a JSONObject into a cookie list. A cookie list is a sequence * of name/value pairs. The names are separated from the values by '='. * The pairs are separated by ';'. The characters '%', '+', '=', and ';' * in the names and values are replaced by "%hh". * @param o A JSONObject * @return A cookie list string * @throws JSONException */ public static String toString(JSONObject o) throws JSONException { boolean b = false; Iterator<?> keys = o.keys(); String s; StringBuffer sb = new StringBuffer(); while (keys.hasNext()) { s = keys.next().toString(); if (!o.isNull(s)) { if (b) { sb.append(';'); } sb.append(Cookie.escape(s)); sb.append("="); sb.append(Cookie.escape(o.getString(s))); b = true; } } return sb.toString(); } }
JSONArray versions = issue.getJSONArray("fixVersions"); epicAsString = versions.getJSONObject(0).getString("name"); for(int j = 0; j < versions.length() ; j++){ JSONObject version = versions.getJSONObject(j); if (version.getString("name").toLowerCase().contains("iteration")){ epicAsString = version.getString("name"); break;
Resty.content(new JSONObject(payload))); if (r == null) return false; String accessToken = r.object().getString("access_token"); if (accessToken == null) return false; return connectWithToken(username, accessToken);
System.out.println(" to: " + j.getString("to")); System.out.println(" true: " + j.getString("true")); System.out.println(" foo: " + j.getJSONArray("foo")); System.out.println(" op: " + j.getString("op")); System.out.println(" ten: " + j.getInt("ten")); System.out.println(" oops: " + j.optBoolean("oops")); while (it.hasNext()) { s = (String)it.next(); System.out.println(s + ": " + j.getString(s));
System.out.println(" to: " + j.getString("to")); System.out.println(" true: " + j.getString("true")); System.out.println(" foo: " + j.getJSONArray("foo")); System.out.println(" op: " + j.getString("op")); System.out.println(" ten: " + j.getInt("ten")); System.out.println(" oops: " + j.optBoolean("oops")); while (it.hasNext()) { s = (String)it.next(); System.out.println(s + ": " + j.getString(s));