Skip to content

Instantly share code, notes, and snippets.

@victorbstan
Forked from anonymous/gist:508722
Created August 4, 2010 20:21
Show Gist options
  • Save victorbstan/508725 to your computer and use it in GitHub Desktop.
Save victorbstan/508725 to your computer and use it in GitHub Desktop.
function normalizeData2(data, intoArray) {
for(var key in data) {
var value = data[key];
if (typeof(value) === 'object') {
normalizeData2(value, intoArray);
} else {
pair = [key, value];
intoArray.push(pair);
}
}
}
function normalizeData(data) {
var result = [];
normalizeData2(data, result);
return result;
}
var myData = {
'a': 'b',
'c': {
'd':'e'
}
};
alert(normalizeData(myData));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment