Last active
January 21, 2021 15:38
-
-
Save lauroguedes/dfe79766c5938331d7c1c3c767aa4483 to your computer and use it in GitHub Desktop.
Javascript Function to formatted json
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
| function formatJson(content, formatted = false) { | |
| var fixContent = content.replace(/"/g,'"'); | |
| if (formatted) { | |
| var jsonObj = JSON.parse(fixContent); | |
| return JSON.stringify(jsonObj, null, 2) | |
| } | |
| return fixContent; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment