Created
April 18, 2012 17:25
-
-
Save diegoponciano/2415252 to your computer and use it in GitHub Desktop.
pog pra acessar as propriedades de um json estranho da "firma"
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
json = {/*json object with lots of properties*/}; | |
var strings = []; | |
for (var jsonProp in json) { | |
if (json.hasOwnProperty(jsonProp)) { | |
jsonObj = json[jsonProp]; | |
for (var i=0; i<jsonObj.length; i++) { | |
if(typeof(jsonObj[i]) === 'string'){ | |
strings.push(jsonObj[i]); | |
} | |
else { | |
if(typeof jsonObj[i].key === 'undefined') { | |
for (var subProp in jsonObj[i]) { | |
if (jsonObj[i].hasOwnProperty(subProp)) { | |
subPropHolder = jsonObj[i]; | |
strings.push(subPropHolder[subProp]); | |
} | |
} | |
} | |
else | |
strings.push(jsonObj[i].key); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment