Skip to content

Commit

Permalink
can reforman JSON bodies now
Browse files Browse the repository at this point in the history
  • Loading branch information
mookid8000 committed Aug 27, 2015
1 parent 269a937 commit 90f3092
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
17 changes: 16 additions & 1 deletion Rebus.Snoop/Listeners/MsmqInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -683,8 +684,10 @@ bool TryDecodeBody(System.Messaging.Message message, Dictionary<string, string>
{
var bytes = reader.ReadBytes((int)message.BodyStream.Length);
var str = encoder.GetString(bytes);
body = str;

body = TryToIndentJson(str);
bodySize = bytes.Length;

return true;
}
}
Expand All @@ -696,6 +699,18 @@ bool TryDecodeBody(System.Messaging.Message message, Dictionary<string, string>
}
}

string TryToIndentJson(string jsonText)
{
try
{
return JsonConvert.SerializeObject(JsonConvert.DeserializeObject<JObject>(jsonText), Formatting.Indented);
}
catch
{
return jsonText;
}
}

static int GetLengthFromStreamIfPossible(System.Messaging.Message message)
{
try
Expand Down
2 changes: 1 addition & 1 deletion Rebus.Snoop/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<GroupBox Header="Headers" Grid.Row="0">
<GroupBox Header="Headers" Grid.Row="0" MaxHeight="200">
<ListView ItemsSource="{Binding Machines/Queues/Messages/HeadersExceptError}">
<ListView.Resources>
<DataTemplate x:Key="HeaderValueCellTemplate">
Expand Down
4 changes: 4 additions & 0 deletions packages/repositories.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\Rebus.Snoop\packages.config" />
</repositories>

0 comments on commit 90f3092

Please sign in to comment.