File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
CodeBeam.MudBlazor.Extensions/Components/JsonTreeView Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 3434 }
3535 break ;
3636 case JsonValueKind .Number :
37- var number = child .Value .AsValue ().GetValue <int >();
38- < MudTreeViewItem T = " string" Text = " @child.Key" Icon = " @Icons.Material.Filled.Numbers" EndText = " @number.ToString()" >< / MudTreeViewItem >
37+ JsonValue jsonVal = child .Value .AsValue ();
38+ string endText = string .Empty ;
39+ @* We try for int first, because an int can always be converted to double but not the other way around*@
40+ if (jsonVal.TryGetValue<int>(out int intVal ))
41+ {
42+ endText = intVal .ToString ();
43+ }
44+ else if (jsonVal .TryGetValue <double >(out double doubleVal ))
45+ {
46+ endText = doubleVal .ToString ();
47+ }
48+ < MudTreeViewItem T = " string" Text = " @child.Key" Icon = " @Icons.Material.Filled.Numbers" EndText = " @endText" >< / MudTreeViewItem >
3949 break ;
4050 case JsonValueKind .True :
4151 < MudTreeViewItem T = " string" Text = " @child.Key" Icon = " @Icons.Material.Filled.CheckBox" EndText = " true" >< / MudTreeViewItem >
You can’t perform that action at this time.
0 commit comments