Skip to content

Instantly share code, notes, and snippets.

@guilhermedecampo
Created July 15, 2016 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermedecampo/284bc153fdcdcd4343590887b9145379 to your computer and use it in GitHub Desktop.
Save guilhermedecampo/284bc153fdcdcd4343590887b9145379 to your computer and use it in GitHub Desktop.
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