Skip to content

Instantly share code, notes, and snippets.

@cosminpopescu14
Created October 18, 2018 05:01
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 cosminpopescu14/5658d533220e9f9a17026ec7e2efb15a to your computer and use it in GitHub Desktop.
Save cosminpopescu14/5658d533220e9f9a17026ec7e2efb15a to your computer and use it in GitHub Desktop.
Just a simple blazor page
@page "/big_json"
@inject HttpClient Http
@if (friends == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Email</th>
<th>Company</th>
</tr>
</thead>
<tbody>
@foreach (var friend in friends)
{
<tr>
<td>@friend.name</td>
<td>@friend.gender</td>
<td>@friend.email</td>
<td>@friend.company</td>
</tr>
}
</tbody>
</table>
}
@functions{
RootObject[] friends;
protected override async Task OnInitAsync()
{
friends = await Http.GetJsonAsync<RootObject[]>("http://www.json-generator.com/api/json/get/bIphkcEgSW?indent=2");
}
public class Friend
{
public int id { get; set; }
public string name { get; set; }
}
public class RootObject
{
public string _id { get; set; }
public int index { get; set; }
public string guid { get; set; }
public bool isActive { get; set; }
public string balance { get; set; }
public string picture { get; set; }
public int age { get; set; }
public string eyeColor { get; set; }
public string name { get; set; }
public string gender { get; set; }
public string company { get; set; }
public string email { get; set; }
public string phone { get; set; }
public string address { get; set; }
public string about { get; set; }
public string registered { get; set; }
public double latitude { get; set; }
public double longitude { get; set; }
public List<string> tags { get; set; }
public List<Friend> friends { get; set; }
public string greeting { get; set; }
public string favoriteFruit { get; set; }
}
}
@cosminpopescu14
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment