Last active
July 22, 2017 12:49
-
-
Save szkrd/dbaba0ec19f3fa7a1f6921339d26c3fb to your computer and use it in GitHub Desktop.
prettify json for spec console logs
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
// dumb | |
console.log('>>>\n' + JSON.stringify(instance.state, null, 2).replace(/ "([a-zA-Z_]*)": /g, ' $1: ').replace(/ "([^"]*)"(,?)/g, ' \'$1\'$2') + '\n<<<'); | |
// dumber | |
console.log('>>>\n' + JSON.stringify(result, null, 2).replace(/"/g, '\'').replace(/(\s+)'([^']*)'(: )/g, '$1$2$3')) + '\n<<<') | |
// copy-paste to console | |
copy(JSON.stringify(temp1, null, 2).replace(/"/g, '\'').replace(/(\s+)'([^']*)'(: )/g, '$1$2$3'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment