private static async Task <bool> FormatJsonAsync(HttpState programState, IWritable outputSink, HttpContent content, StreamWriter bodyFileWriter) { string responseContent = await content.ReadAsStringAsync().ConfigureAwait(false); try { JsonConfig config = new JsonConfig(programState); string formatted = JsonVisitor.FormatAndColorize(config, responseContent); outputSink.WriteLine(formatted); bodyFileWriter.WriteLine(JToken.Parse(responseContent).ToString()); return(true); } catch { } return(false); }
private static async Task <bool> FormatJsonAsync(IWritable outputSink, HttpContent content, List <string> bodyFileOutput, IPreferences preferences) { string responseContent = await content.ReadAsStringAsync().ConfigureAwait(false); try { JsonConfig config = new JsonConfig(preferences); string formatted = JsonVisitor.FormatAndColorize(config, responseContent); outputSink.WriteLine(formatted); bodyFileOutput?.Add(JToken.Parse(responseContent).ToString()); return(true); } catch { } return(false); }
public void JsonVisitor_ObjectWithComments() { string testData = @"[ { //Object 1 ""property"": ""value"", ""and"": ""again"" }, { //Object 2 }, [ //An array ], null, 1, 3.2, ""test"", false ]"; string formatted = JsonVisitor.FormatAndColorize(new MockJsonConfig(), testData); }