Skip to content

Instantly share code, notes, and snippets.

@arnaudoff
Created February 18, 2016 17:29
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 arnaudoff/710c2fa78f29aa6e61eb to your computer and use it in GitHub Desktop.
Save arnaudoff/710c2fa78f29aa6e61eb to your computer and use it in GitHub Desktop.
Trello JSON export to human readable cards
var obj = JSON.parse(json);
function getMilestone(cardLabels) {
for(var i = 0; i < cardLabels.length; i++) {
if (cardLabels[i].name === 'High priority' || cardLabels[i].name === 'Critical priority') {
return 1;
} else if (cardLabels[i].name == 'Medium priority') {
return 2;
} else if (cardLabels[i].name == 'Low priority') {
return 3;
}
}
}
function makeReadable(obj) {
return obj.cards.map(function (card) {
return {
name: card.name,
desc: card.desc,
labels: card.labels.map(function (label) {
return label.name;
}),
milestone: getMilestone(card.labels)
}
})
}
var result = makeReadable(obj);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment