/// <summary> /// This method is the main entry point to create the various weekly JSON /// analysis files. A total of four files will be created, one for each /// type of analysis (DropRAT, DropMixBand, FailRAT, FailMixBand) within the /// specified output directory. Minification of the file is available to /// save space if required. /// </summary> /// <param name="directory">The output directory</param> /// <param name="minify">Whether or not to minify the results</param> public void CreateWeeklyAnalysisJSON(String directory, Boolean minify = true) { // Ensure there is a trailing backslash upon the directory directory = directory.TrimEnd('\\') + @"\"; // Obtain the JSON String String drop_rats = MergeDropRATJSON(); String drop_mixbands = MergeDropMixBandJSON(); String fail_rats = MergeFailRATJSON(); String fail_mixbands = MergeFailMixBandJSON(); // Check to see if the output requires prettifying (un-minifying) if (!minify) { drop_rats = JSONWriter.PrettifyJSON(drop_rats); drop_mixbands = JSONWriter.PrettifyJSON(drop_mixbands); fail_rats = JSONWriter.PrettifyJSON(fail_rats); fail_mixbands = JSONWriter.PrettifyJSON(fail_mixbands); } // Create each output file File.WriteAllText(directory + "weekly_drop_rat.json", drop_rats); File.WriteAllText(directory + "weekly_drop_mix_band.json", drop_mixbands); File.WriteAllText(directory + "weekly_fail_rat.json", fail_rats); File.WriteAllText(directory + "weekly_fail_mix_band.json", fail_mixbands); }
public void TestPrettifyJSON() { // The input JSON String String input = "{ \"name\": \"Dave\", \"age\": \"30\" }"; // The expected JSON String (note: neeeds to contain the indentations) String expected = "{\r\n \"name\": \"Dave\",\r\n \"age\": \"30\" \r\n}"; // The actual JSON String String actual = JSONWriter.PrettifyJSON(input); // Ensure the expected JSON String and the actual JSON String are equal Assert.AreEqual(expected, actual); }