codice:Option Strict On Imports Newtonsoft.Json Partial Class deserializzo_json_array Inherits System.Web.UI.Page Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim wc As System.Net.WebClient = Nothing Try wc = New System.Net.WebClient() 'Dim url As String = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-json/dpc-covid19-ita-andamento-nazionale.json" 'Dim s As String = wc.DownloadString(url) Dim s As String = File.ReadAllText(Server.MapPath("json_array.txt")) Dim r As List(Of Class1) = If(Not String.IsNullOrWhiteSpace(s), JsonConvert.DeserializeObject(Of List(Of Class1))(s), New List(Of Class1)()) Dim sb As New StringBuilder() sb.Append("<table id=""table1"" >") sb.Append("<thead><tr>") Dim t As Type = GetType(Class1) For Each p In t.GetProperties() Dim nome As String = p.Name sb.AppendFormat("<th>{0}</th>", nome) Next sb.Append("</tr></thead>") sb.Append("<tbody>") For Each f In r sb.Append("<tr>") t = f.GetType For Each p In t.GetProperties() Dim nome As String = p.Name Dim tipo As String = p.PropertyType.ToString Dim valore As String = l.NullToString(p.GetValue(f, Nothing)) sb.AppendFormat("<td class=""center"">{0}</td>", valore) Next sb.Append("</tr>") Next sb.Append("</tbody>") sb.Append("</table>") Me.Literal1.Text = sb.ToString Catch ex As Exception Me.Label1.Text = l.exMessageErrorForLabel(ex) End Try End Sub Public Class Class1 Public Property data As Date Public Property stato As String Public Property ricoverati_con_sintomi As Integer Public Property terapia_intensiva As Integer Public Property totale_ospedalizzati As Integer Public Property isolamento_domiciliare As Integer Public Property totale_attualmente_positivi As Integer Public Property nuovi_attualmente_positivi As Integer Public Property dimessi_guariti As Integer Public Property deceduti As Integer Public Property totale_casi As Integer Public Property tamponi As Integer Public Property note_it As String Public Property note_en As String End Class End Class

Rispondi quotando