From efc89be81c1270cc7da383f373f3ad468867dbce Mon Sep 17 00:00:00 2001 From: cmos12345 <44764541+cmos12345@users.noreply.github.com> Date: Sat, 31 Aug 2024 10:43:13 +0200 Subject: [PATCH] Fixed rendering of numeric double values --- .../JsonTreeView/MudJsonTreeViewNode.razor | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CodeBeam.MudBlazor.Extensions/Components/JsonTreeView/MudJsonTreeViewNode.razor b/CodeBeam.MudBlazor.Extensions/Components/JsonTreeView/MudJsonTreeViewNode.razor index 65fd6835..a744e506 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/JsonTreeView/MudJsonTreeViewNode.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/JsonTreeView/MudJsonTreeViewNode.razor @@ -34,8 +34,18 @@ } break; case JsonValueKind.Number: - var number = child.Value.AsValue().GetValue(); - + 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(out int intVal)) + { + endText = intVal.ToString(); + } + else if (jsonVal.TryGetValue(out double doubleVal)) + { + endText = doubleVal.ToString(); + } + break; case JsonValueKind.True: