Skip to content

Instantly share code, notes, and snippets.

@waltzaround
Created October 18, 2015 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waltzaround/6bb700d69d29703b3fef to your computer and use it in GitHub Desktop.
Save waltzaround/6bb700d69d29703b3fef to your computer and use it in GitHub Desktop.
string currencyURL = "http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json";
WWW currencyWWW = new WWW (currencyURL);
yield return currencyWWW;
JSONObject j = new JSONObject(currencyWWW);
accessData(j);
//access data (and print it)
void accessData(JSONObject obj){
switch(obj.type){
case JSONObject.Type.OBJECT:
for(int i = 0; i < obj.list.Count; i++){
string key = (string)obj.keys[i];
JSONObject j = (JSONObject)obj.list[i];
Debug.Log(key);
accessData(j);
}
break;
case JSONObject.Type.ARRAY:
foreach(JSONObject j in obj.list){
accessData(j);
}
break;
case JSONObject.Type.STRING:
Debug.Log(obj.resources.resource.name);
break;
case JSONObject.Type.NUMBER:
Debug.Log(obj.resources.resource.price);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment