List of usage examples for org.json.simple JSONObject keySet
Set<K> keySet();
From source file:minor.commodity.CommodityQuote.java
@Override public String execute() { System.out.println("Ticker in Commodity Quote: " + getCticker()); System.out.println("Checking"); //List<CommodityDetails> sd2 = cdf.getCommodityData(getCticker()); //System.out.println("Size of return Value: "+sd2.size()); /*/*from w w w. j a va 2s. co m*/ for(CommodityDetails cd : sd2){ cdf.create(cd); }*/ JSONObject quote = commodityDetailsFacade.getCommodityData(getCticker()); System.out.println("Array List: " + quote.toJSONString()); //System.out.println("CDF String: "+cdf.toString()); //System.out.println("Checking again"); Set<String> st = quote.keySet(); try { for (String s : st) { if (quote.get(s) == null) { System.out.println("IN IF"); //quote.remove(s); quote.put(s, "NA"); } } } catch (Exception e) { System.out.println(e); } CommodityDetails cd = new CommodityDetails(quote); System.out.println(cd.getPERatio()); System.out.println(cd.getEBITDA()); System.out.println(cd.getPreviousClose()); System.out.println(cd.getDaysHigh()); System.out.println(cd.getVolume()); setSd(cd); //setSd(sd.add(cd)); if (true) { return "success"; } else { System.out.println("Checking again again"); return "error"; } }
From source file:com.jadarstudios.rankcapes.bukkit.RankCapesBukkit.java
/** * Parses cape pack metadata.//from www . ja va 2 s .com * * @param input zip input stream of the cape pack. */ private void parseMetadata(ZipInputStream input) throws InvalidCapePackException, IOException, ParseException { Object root = JSONValue.parseWithException(new InputStreamReader(input)); JSONObject object = (JSONObject) root; CapePackValidator.validatePack(object); for (Object key : object.keySet()) { if (key instanceof String) { this.availableCapes.add((String) key); } } }
From source file:functions.TestOptions.java
@Test public void testLoadconfig() { try {//from ww w .ja va 2 s.c o m JSONObject inputJSON = ParseOptions.parseSingleJsonFile(testconfig); assertTrue(inputJSON.keySet().size() > 0); } catch (ParseException e) { // e.printStackTrace(); } }
From source file:com.xtructure.xutil.ValueMap.java
/** * Instantiates a new value map.// www . ja v a 2 s . c om * * @param jsonObject the json object */ public ValueMap(JSONObject jsonObject) { this(); for (Object key : jsonObject.keySet()) { XValId<?> id = XValId.TEXT_FORMAT.parse(key.toString()); Object value; if (ValueType.STRING.isTypeOf(id)) { value = jsonObject.get(key).toString(); } else { TextFormat<?> tf = TextFormat.getInstance(id.getType()); value = tf.parse(jsonObject.get(key).toString()); } map.put(id, value); } }
From source file:com.janoz.tvapilib.fanarttv.impl.FanartTvImpl.java
@Override public void addFanart(Sh show) { int theTvDbId = show.getTheTvDbId(); Reader r = new InputStreamReader(openStream(getUrl(theTvDbId))); JSONObject showArt = (JSONObject) JSONValue.parse(r); //validate/*from www . j a va 2 s.com*/ String receivedTvDbId = (String) showArt.get("thetvdb_id"); if (!receivedTvDbId.equals("" + theTvDbId)) { throw new TvApiException("Unexpected result. Wrong TVDB id."); } for (String key : (Set<String>) showArt.keySet()) { if (artMapping.containsKey(key)) { List<JSONObject> artArray = (List<JSONObject>) showArt.get(key); parsArtArray(show, key, artArray); } } }
From source file:com.netflix.dynomitemanager.monitoring.ServoMetricsTask.java
/** * Helper to recursively flatten out a metric from a nested collection * @param namePrefix/* w w w . j av a 2 s . c om*/ * @param obj */ private void parseObjectMetrics(String namePrefix, JSONObject obj) { for (Object key : obj.keySet()) { Object val = obj.get(key); if (val instanceof JSONObject) { parseObjectMetrics(namePrefix + "__" + key, (JSONObject) val); } else { if (gaugeFilter.get().contains((String) key)) { processGaugeMetric(namePrefix + "__" + (String) key, (Long) val); } else { processCounterMetric(namePrefix + "__" + (String) key, (Long) val); } } } }
From source file:me.timothy.ddd.entities.EntityConversationInfo.java
@Override public void loadFrom(JSONObject jsonObject) { Set<?> keys = jsonObject.keySet(); for (Object o : keys) { if (o instanceof String) { String key = (String) o; switch (key.toLowerCase()) { case "text": JSONArray arr = getArray(jsonObject, key); text = new ArrayList<>(); for (Object o2 : arr) { if (o2 instanceof JSONObject) { ConversationMessage cm = new ConversationMessage(); cm.loadFrom((JSONObject) o2); text.add(cm);//w ww . j av a 2s . c om } } break; case "quest": quest = getString(jsonObject, key); break; default: logger.warn("Unknown key: " + key); } } } }
From source file:mml.handler.scratch.ScratchVersionSet.java
private void parseResource(String resource) { JSONObject jObj = (JSONObject) JSONValue.parse(resource); this.otherFields = new HashMap<String, Object>(); Set<String> keys = jObj.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String key = iter.next(); if (key.equals(JSONKeys._ID)) continue; else if (key.equals(JSONKeys.DOCID)) docid = (String) jObj.get(JSONKeys.DOCID); else if (key.equals(JSONKeys.BODY)) body = (String) jObj.get(JSONKeys.BODY); else if (key.equals(JSONKeys.VERSION1)) version1 = (String) jObj.get(JSONKeys.VERSION1); else if (key.equals(JSONKeys.FORMAT)) format = (String) jObj.get(JSONKeys.FORMAT); else/*from ww w .j a v a2s .c o m*/ otherFields.put(key, jObj.get(key)); } }
From source file:com.ge.research.semtk.sparqlX.SparqlEndpointInterface.java
/** * Parse an auth query confirmation. The message will the first entry in the rows array. * @param rowsJsonArray/*ww w .ja va 2 s . c o m*/ * @return */ private static String getAuthMessageFromResponse(JSONArray rowsJsonArray) { String message = ""; for (int i = 0; i < rowsJsonArray.size(); i++) { JSONObject row = (JSONObject) rowsJsonArray.get(i); // e.g. {"callret-0":{"type":"literal","value":"Insert into <http:\/\/research.ge.com\/dataset>, 1 (or less) triples -- done"}} JSONObject value; String key, valueValue; @SuppressWarnings("unchecked") Iterator<String> iter = row.keySet().iterator(); while (iter.hasNext()) { key = (String) iter.next(); value = (JSONObject) row.get(key); valueValue = (String) value.get("value"); message += valueValue; } } return message; }
From source file:info.pancancer.arch3.persistence.PostgreSQL.java
public List<Job> getJobs(JobState status) { List<Job> jobs = new ArrayList<>(); Map<Object, Map<String, Object>> map; if (status != null) { map = this.runSelectStatement("select * from job where status = ?", new KeyedHandler<>("job_uuid"), status.toString());/* w w w . j av a2s. c o m*/ } else { map = this.runSelectStatement("select * from job", new KeyedHandler<>("job_uuid")); } for (Entry<Object, Map<String, Object>> entry : map.entrySet()) { Job j = new Job(); j.setState(Enum.valueOf(JobState.class, (String) entry.getValue().get("status"))); j.setUuid((String) entry.getValue().get("job_uuid")); j.setWorkflow((String) entry.getValue().get("workflow")); j.setWorkflowVersion((String) entry.getValue().get("workflow_version")); j.setJobHash((String) entry.getValue().get("job_hash")); j.setStdout((String) entry.getValue().get("stdout")); j.setStderr((String) entry.getValue().get("stderr")); JSONObject iniJson = Utilities.parseJSONStr((String) entry.getValue().get("ini")); HashMap<String, String> ini = new HashMap<>(); for (Object key : iniJson.keySet()) { ini.put((String) key, (String) iniJson.get(key)); } j.setIni(ini); // timestamp Timestamp createTs = (Timestamp) entry.getValue().get("create_timestamp"); Timestamp updateTs = (Timestamp) entry.getValue().get("update_timestamp"); j.setCreateTs(createTs); j.setUpdateTs(updateTs); jobs.add(j); } return jobs; }