Created
June 11, 2015 03:40
-
-
Save battleguard/835448a00bcb9bd9bcf2 to your computer and use it in GitHub Desktop.
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
| private static void FormatJsonFile() | |
| { | |
| string jsonText = File.ReadAllText("Modules.json"); | |
| string goodText; | |
| string[] textSplits = jsonText.Split('[', ']'); | |
| goodText = textSplits[0]; | |
| for (int i = 1; i < textSplits.Length; i+=2) | |
| { | |
| goodText += "[\r\n"; | |
| string textToFormat = textSplits[i]; | |
| string formattedText = textToFormat.Replace("\r", "").Replace("\n", ""); | |
| goodText += FormatCurlies(formattedText); | |
| string textToAppent = "\t]" + textSplits[i + 1] ; | |
| goodText += textToAppent; | |
| } | |
| File.WriteAllText("ModulesFormatted.json", goodText); | |
| } | |
| private static string FormatCurlies(string text) | |
| { | |
| string goodText = ""; | |
| string[] textSplits = text.Split('{', '}'); | |
| if (textSplits.Length == 1) | |
| return text; | |
| for(int i = 1; i < textSplits.Length; i+=2) | |
| { | |
| string maintext = textSplits[i]; | |
| string append = textSplits[i + 1]; | |
| goodText += "\t\t{" + maintext + "}" + append + "\r\n"; | |
| } | |
| return goodText; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment