List of usage examples for twitter4j JSONObject keys
public Iterator<String> keys()
From source file:com.sampleapp.db.DBUtil.java
License:Open Source License
private DBUtil() { Map<String, String> env; env = System.getenv();/*from ww w. j ava2 s.co m*/ String vcap = env.get("VCAP_SERVICES"); if (vcap == null) { System.out.println("No VCAP_SERVICES found"); return; } System.out.println("VCAP_SERVICES found"); try { JSONObject vcap_services = new JSONObject(vcap); @SuppressWarnings("rawtypes") Iterator iter = vcap_services.keys(); JSONArray cloudant = null; // find instance of cloudant bound to app while (iter.hasNext()) { String key = (String) iter.next(); if (key.startsWith("cloudantNoSQLDB")) { cloudant = vcap_services.getJSONArray(key); } } JSONObject instance = cloudant.getJSONObject(0); // Grab the first instance of mongoDB for this app (there is only one) JSONObject credentials = instance.getJSONObject("credentials"); // Get all VCAP_SERVICES credentials String host = credentials.getString("host"); String port = credentials.getString("port"); String username = credentials.getString("username"); String password = credentials.getString("password"); String url = credentials.getString("url"); System.out.println("Found all the params: " + username + " " + password + " " + url); // Create the client connection the the database and then create the database client = new CloudantClient(url, username, password); db = client.database(dbname, true); System.out.println("Connected to cloudant on " + host + ":" + port); } catch (Exception e) { e.printStackTrace(); } }