I am using the MVC template from .net and I can show my json but now i want to parse it to html, preferrably in a table, so it looks better.
I get the json from my HomeController.cs to my View which is About.cshtml but it's just the json string, so it looks horrible.
public class HomeController : Controller
{
public JsonResult TestJson()
{
var client = new WebClient();
var response = client.DownloadString(new Uri("http://localhost:8080/projecten/api/leerlingen"));
var someObject = JsonConvert.DeserializeObject(response);
return new JsonResult() { Data = someObject, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
public ActionResult About()
{
var client = new WebClient();
var json = client.DownloadString(new Uri("http://localhost:8080/projecten/api/leerlingen"));
//parse json
ViewBag.Message = json;
return View();
}
}
this it the json
[{"inschrijvingsNummer":"0001","naam":"John Smith","email":"[email protected]","evaluatieNummer":"270"},
{"inschrijvingsNummer":"0002","naam":"Joe Bloggs","email":"[email protected]","evaluatieNummer":"370"}]
to html with .net i show it in this page (About.cshtml)
@{
ViewBag.Title = "Evaluaties";
}
<h2>@ViewBag.Title.</h2>
<p>@ViewBag.Message</p>