Created
January 17, 2019 21:22
-
-
Save excenter/055dad5f0a8a09d058e8b24b55ea4115 to your computer and use it in GitHub Desktop.
it's like minify, but different in subtle ways important to few people.
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
function jsonSquish(contents){ | |
// remove all line breaks | |
// console.log(contents) | |
contents = contents.replace(/\r?\n|\r/g,"") | |
contents = contents.replace(/"/g, '\"\"') | |
// console.log(contents) | |
// compress all multiple spaces down to one space | |
change = "" | |
for(;change !== contents;){ | |
// console.log(contents) | |
change = contents; | |
contents = contents.replace(/ /g," ") | |
} | |
// console.log(contents) | |
return contents | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment