Skip to content

Commit

Permalink
Fixed rendering of numeric double values (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmos12345 authored Sep 2, 2024
1 parent 732ea9a commit 78db927
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,18 @@
}
break;
case JsonValueKind.Number:
var number = child.Value.AsValue().GetValue<int>();
<MudTreeViewItem T="string" Text="@child.Key" Icon="@Icons.Material.Filled.Numbers" EndText="@number.ToString()"></MudTreeViewItem>
JsonValue jsonVal = child.Value.AsValue();
string endText = string.Empty;
@* We try for int first, because an int can always be converted to double but not the other way around*@
if (jsonVal.TryGetValue<int>(out int intVal))
{
endText = intVal.ToString();
}
else if (jsonVal.TryGetValue<double>(out double doubleVal))
{
endText = doubleVal.ToString();
}
<MudTreeViewItem T="string" Text="@child.Key" Icon="@Icons.Material.Filled.Numbers" EndText="@endText"></MudTreeViewItem>
break;
case JsonValueKind.True:
<MudTreeViewItem T="string" Text="@child.Key" Icon="@Icons.Material.Filled.CheckBox" EndText="true"></MudTreeViewItem>
Expand Down

0 comments on commit 78db927

Please sign in to comment.