Skip to content

Instantly share code, notes, and snippets.

@diegoponciano
Created April 18, 2012 17:25
Show Gist options
  • Save diegoponciano/2415252 to your computer and use it in GitHub Desktop.
Save diegoponciano/2415252 to your computer and use it in GitHub Desktop.
pog pra acessar as propriedades de um json estranho da "firma"
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