List of usage examples for org.json.simple JSONObject get
V get(Object key);
From source file:com.orthancserver.OrthancConnection.java
public static OrthancConnection Unserialize(JSONObject json) { OrthancConnection c = new OrthancConnection(); c.SetName((String) json.get("Name")); c.SetBaseUrl((String) json.get("Url")); if (json.containsKey("Authentication")) { c.authentication_ = (String) json.get("Authentication"); } else {// w ww. ja v a2s. c om c.authentication_ = null; } return c; }
From source file:com.cisco.tbd.stec.client.ServerConnection.java
public static JSONArray pullNewRules(String timeStamp) throws IOException, ParseException { String request = "http://10.154.244.56/stec/get_threats.php?token=weiuyrwerywiuery&exchange=1&from=" + timeStamp;/*from w w w .j a v a2s . c om*/ HttpClient client = new HttpClient(); GetMethod method = new GetMethod(request); int statusCode = client.executeMethod(method); InputStream rstream = null; rstream = method.getResponseBodyAsStream(); BufferedReader br = new BufferedReader(new InputStreamReader(rstream)); JSONObject json = (JSONObject) new JSONParser().parse(br.readLine()); //System.out.println(json.toString()); String newTimeStamp = json.get("timestamp").toString(); JSONArray rules = (JSONArray) json.get("data"); br.close(); if (FileUtils.removeFile(Runner.PATH_TO_TIME_STAMP_FILE)) { FileUtils.createFileWithText(Runner.PATH_TO_TIME_STAMP_FILE, newTimeStamp); } return rules; }
From source file:com.github.itoshige.testrail.util.ConfigrationUtil.java
private static boolean assureBoolean(JSONObject jsonObject, String key) { try {/*from ww w. j ava2 s. com*/ return (Boolean) jsonObject.get(key); } catch (Exception e) { throw new TestInitializerException(String.format("key:%s is invalid.", key)); } }
From source file:fr.free.movierenamer.utils.JSONUtils.java
public static String selectString(String attribute, final JSONObject node) { try {/*from w w w .java 2s . c o m*/ if (node == null) { return null; } else { Object val = node.get(attribute); if (val == null) { return null; } else { return String.valueOf(val); } } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.github.itoshige.testrail.util.ConfigrationUtil.java
/** * get packages of target runId//w w w.j a v a2 s .c o m * * @param runId * @return */ public static List<String> getPackages(String runId) { JSONObject jsonObject = getConfig(); JSONArray runIds = (JSONArray) jsonObject.get("runIds"); List<String> packages = new ArrayList<String>(); for (RunIdInfo runIdInfo : getRunIdInfos(runIds)) { if (runIdInfo.getRunId().equals(runId)) { packages.add(runIdInfo.getTarget()); } } return packages; }
From source file:com.rmtheis.yandtran.YandexTranslatorAPI.java
private static String[] jsonObjValToStringArr(final String inputString, final String subObjPropertyName) throws Exception { JSONObject jsonObj = (JSONObject) JSONValue.parse(inputString); JSONArray jsonArr = (JSONArray) jsonObj.get(subObjPropertyName); return jsonArrToStringArr(jsonArr.toJSONString(), null); }
From source file:com.github.itoshige.testrail.util.ConfigrationUtil.java
/** * get runId of target test./* w ww. ja va 2s. c om*/ * * @param packageName * @return */ public static String getRunId(String classPath) { JSONObject jsonObject = getConfig(); JSONArray runIds = (JSONArray) jsonObject.get("runIds"); for (RunIdInfo runIdInfo : getRunIdInfos(runIds)) { if (classPath.indexOf(runIdInfo.getTarget()) != -1) { logger.debug("target path:{}", runIdInfo.getTarget()); return runIdInfo.getRunId(); } } throw new TestInitializerException( String.format("classPath:%s isn't defined runId in %s.", classPath, CONFIG_FILE)); }
From source file:edu.rit.chrisbitler.ritcraft.slackintegration.rtm.UserList.java
/** * Query the slack api to get the list of users and their real names. This is done whenever we can't find an ID mapping, * and when the plugin loads/* w w w . ja v a 2s. c o m*/ */ public static void queryUsers() { try { users.clear(); //Contact the slack api to get the user list HttpURLConnection conn = (HttpURLConnection) new URL( "https://www.slack.com/api/users.list?token=" + SlackIntegration.BOT_TOKEN).openConnection(); conn.connect(); JSONObject retVal = (JSONObject) JSONValue .parse(new InputStreamReader((InputStream) conn.getContent())); JSONArray members = (JSONArray) retVal.get("members"); //Loop through the members and add them to the map Iterator<JSONObject> iter = members.iterator(); while (iter.hasNext()) { JSONObject obj = iter.next(); JSONObject profile = (JSONObject) obj.get("profile"); String id = (String) obj.get("id"); String realName = (String) profile.get("real_name"); users.put(id, realName); } } catch (IOException e) { e.printStackTrace(); } }
From source file:com.facebook.tsdb.tsdash.server.model.MetricQuery.java
public static HashMap<String, String> decodeTags(JSONObject tagsObj) { HashMap<String, String> tags = new HashMap<String, String>(); for (Object tagKeyObj : tagsObj.keySet()) { tags.put((String) tagKeyObj, (String) tagsObj.get(tagKeyObj)); }/*from w w w. ja v a 2s . c o m*/ return tags; }
From source file:fr.free.movierenamer.utils.JSONUtils.java
public static JSONObject selectObject(String path, final JSONObject rootObject) { try {/* ww w . ja va 2s . co m*/ JSONObject toSearch = rootObject; String[] nodes = path.split("/"); for (String node : nodes) { toSearch = (JSONObject) toSearch.get(node); } return toSearch; } catch (Exception e) { throw new RuntimeException(e); } }