-
-
Save victorbstan/508725 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
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