Created
November 1, 2016 18:53
-
-
Save regalstreak/cefe82338431fd5d7e23d0436fa1f741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String[] parseMyJson(String... urls){ | |
String jsonUrl = urls[0]; | |
String[] jsonData = null; | |
try { | |
// Bring in the raw json data to jsonRawData | |
InputStream in1 = new java.net.URL(jsonUrl).openStream(); | |
String jsonRawData = IOUtils.toString(in1, "UTF-8"); | |
in1.close(); | |
// Parse the json to jsonData | |
JSONObject jsonRootObject = new JSONObject(jsonRawData); | |
JSONArray jsonArray = jsonRootObject.optJSONArray("wallieUrls"); | |
// Put the stuff in jsonData | |
for(int i=0; i<jsonArray.length(); i++){ | |
JSONObject jsonObject = jsonArray.getJSONObject(i); | |
jsonData[i] = jsonObject.optString(""); | |
} | |
}catch (Exception e){ | |
Log.e("Error", e.getMessage()); | |
e.printStackTrace(); | |
} | |
return jsonData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment