Skip to content

Instantly share code, notes, and snippets.

@kiasyn
Created April 30, 2020 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiasyn/3d45ebb430be06044d402c15dac75d54 to your computer and use it in GitHub Desktop.
Save kiasyn/3d45ebb430be06044d402c15dac75d54 to your computer and use it in GitHub Desktop.
Blazor json dump object for debugging
@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