From 90f30920eb66b3460ec63ca00bdae4b11f48bd2e Mon Sep 17 00:00:00 2001 From: Mogens Heller Grabe Date: Thu, 27 Aug 2015 22:29:28 +0200 Subject: [PATCH] can reforman JSON bodies now --- Rebus.Snoop/Listeners/MsmqInteraction.cs | 17 ++++++++++++++++- Rebus.Snoop/MainWindow.xaml | 2 +- packages/repositories.config | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 packages/repositories.config diff --git a/Rebus.Snoop/Listeners/MsmqInteraction.cs b/Rebus.Snoop/Listeners/MsmqInteraction.cs index 795c23b..50f9500 100644 --- a/Rebus.Snoop/Listeners/MsmqInteraction.cs +++ b/Rebus.Snoop/Listeners/MsmqInteraction.cs @@ -8,6 +8,7 @@ using System.Windows; using GalaSoft.MvvmLight.Messaging; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Rebus.Messages; using Rebus.Shared; using Rebus.Snoop.Events; @@ -683,8 +684,10 @@ bool TryDecodeBody(System.Messaging.Message message, Dictionary { var bytes = reader.ReadBytes((int)message.BodyStream.Length); var str = encoder.GetString(bytes); - body = str; + + body = TryToIndentJson(str); bodySize = bytes.Length; + return true; } } @@ -696,6 +699,18 @@ bool TryDecodeBody(System.Messaging.Message message, Dictionary } } + string TryToIndentJson(string jsonText) + { + try + { + return JsonConvert.SerializeObject(JsonConvert.DeserializeObject(jsonText), Formatting.Indented); + } + catch + { + return jsonText; + } + } + static int GetLengthFromStreamIfPossible(System.Messaging.Message message) { try diff --git a/Rebus.Snoop/MainWindow.xaml b/Rebus.Snoop/MainWindow.xaml index 453991a..1d48650 100644 --- a/Rebus.Snoop/MainWindow.xaml +++ b/Rebus.Snoop/MainWindow.xaml @@ -146,7 +146,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - + diff --git a/packages/repositories.config b/packages/repositories.config new file mode 100644 index 0000000..8094f62 --- /dev/null +++ b/packages/repositories.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file