Created
July 18, 2016 01:26
-
-
Save windwp/949e5c221c7f4abba3d48a2fe4325ccf to your computer and use it in GitHub Desktop.
Json fix for parse
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
s = s.replace(/\\n/g, "\\n") | |
.replace(/\\'/g, "\\'") | |
.replace(/\\"/g, '\\"') | |
.replace(/\\&/g, "\\&") | |
.replace(/\\r/g, "\\r") | |
.replace(/\\t/g, "\\t") | |
.replace(/\\b/g, "\\b") | |
.replace(/\\f/g, "\\f"); | |
// remove non-printable and other non-valid JSON chars | |
s = s.replace(/[\u0000-\u0019]+/g, ""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment