Created
October 18, 2015 23:27
-
-
Save waltzaround/6bb700d69d29703b3fef to your computer and use it in GitHub Desktop.
This file contains 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
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