Created
July 15, 2016 18:31
-
-
Save guilhermedecampo/284bc153fdcdcd4343590887b9145379 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const json = fetch(jsonURL) | |
const namesColumnTable = _.keys(json); | |
const totalRows = _.reduce(json, (acc, value) => { | |
const arrayLength = _.values(value)[0].length; | |
return arrayLength > acc ? arrayLength : acc; | |
}, 0); | |
const rows = []; | |
rows.push(namesColumnTable); | |
_.times(totalRows, row => { | |
const row = []; | |
_.forEach(json, value => { | |
row.push(value[row] ? value[row] : '') | |
}); | |
rows.push(row); | |
} | |
console.log(rows); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment