Created
April 30, 2020 03:41
-
-
Save kiasyn/3d45ebb430be06044d402c15dac75d54 to your computer and use it in GitHub Desktop.
Blazor json dump object for debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using System.Text.Json | |
<div> | |
@if (!string.IsNullOrEmpty(Label)) | |
{ | |
<h5>@Label</h5> | |
} | |
<code style="display: block; white-space: pre">@json</code> | |
</div> | |
@code { | |
[Parameter] | |
public string Label { get; set; } | |
[Parameter] | |
public object Value { get; set; } | |
string json; | |
protected override async Task OnParametersSetAsync() | |
{ | |
json = JsonSerializer.Serialize(this.Value, new JsonSerializerOptions | |
{ | |
WriteIndented = true | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment