Created
February 18, 2016 17:29
-
-
Save arnaudoff/710c2fa78f29aa6e61eb to your computer and use it in GitHub Desktop.
Trello JSON export to human readable cards
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
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