ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.JSON data not mapping to Class Property in VB.Net<p>Hi <a class="username" rel="arie.keren">arie.keren</a>,</p> <p>Problem is in your Property name which you are assigning in Details class also you need to create master Class object too with property name as same as it comes in json object.</p> <p>Eg. tgl_beli() need to be tanggalBeli as in json result it&rsquo;s come like TanggalBeli also tgl_jtp() need to be tanggalJTP as in json result it&rsquo;s come like TanggalJT And same for rest propery too.</p> <p>Refer the below sample example for your reference.</p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then BindData() End If End Sub Private Sub BindData() Dim isiKTP As String = &#34;3202110611900004&#34; Dim dt As New DataTable() dt.Columns.AddRange(New DataColumn(12) {New DataColumn(&#34;error&#34;, GetType(String)), New DataColumn(&#34;error_message&#34;, GetType(String)), New DataColumn(&#34;MASTER_NoKTP&#34;, GetType(String)), New DataColumn(&#34;MASTER_Nama&#34;, GetType(String)), New DataColumn(&#34;MASTER_AlamatMaster&#34;, GetType(String)), New DataColumn(&#34;DETAIL_TanggalBeli&#34;, GetType(Date)), New DataColumn(&#34;DETAIL_TanggalJTP&#34;, GetType(Date)), New DataColumn(&#34;DETAIL_TipeMotor&#34;, GetType(String)), New DataColumn(&#34;DETAIL_Angsuran&#34;, GetType(Double)), New DataColumn(&#34;DETAIL_Tenor&#34;, GetType(Double)), New DataColumn(&#34;DETAIL_StatusFaktur&#34;, GetType(String)), New DataColumn(&#34;DETAIL_Ke&#34;, GetType(Double)), New DataColumn(&#34;DETAIL_Plat&#34;, GetType(String))}) &#39;currently provided link not working so i read json value from txt file which you have provided. Dim url As String = New System.Net.WebClient().DownloadString(&#34;http://222.124.22.166/nsapi?type=INFOPK&amp;noktp=&#34; &amp; isiKTP) &#39;Copy the result of json string if url not exist for json result and read by using System.IO.File.ReadAllText for testing purpose &#39;Dim url As String = System.IO.File.ReadAllText(Server.MapPath(&#34;~/Json855546.txt&#34;)) Dim jsonArray As JArray = JArray.Parse(&#34;[&#34; + url.Trim() + &#34;]&#34;) For i As Integer = 0 To jsonArray.Count - 1 Dim isiData As Infos = (New JavaScriptSerializer()).Deserialize(Of Infos)(jsonArray(i).ToString()) For j As Integer = 0 To isiData.detail.Count - 1 Dim dr As DataRow = dt.NewRow() Dim dateValue As Date dr(&#34;error&#34;) = isiData.error dr(&#34;error_message&#34;) = isiData.error_message dr(&#34;MASTER_NoKTP&#34;) = isiData.Master(i).NoKTP dr(&#34;MASTER_Nama&#34;) = isiData.Master(i).Nama dr(&#34;MASTER_AlamatMaster&#34;) = isiData.Master(i).AlamatMaster If Date.TryParse(isiData.detail(j).tanggalBeli, dateValue) Then dr(&#34;DETAIL_TanggalBeli&#34;) = Convert.ToDateTime(isiData.detail(j).tanggalBeli, CultureInfo.CurrentCulture).ToString(&#34;yyyy-MM-dd&#34;) Else dr(&#34;DETAIL_TanggalBeli&#34;) = DBNull.Value End If If Date.TryParse(isiData.detail(j).tanggalJTP, dateValue) Then dr(&#34;DETAIL_TanggalJTP&#34;) = Convert.ToDateTime(isiData.detail(j).tanggalJTP, CultureInfo.CurrentCulture).ToString(&#34;yyyy-MM-dd&#34;) Else dr(&#34;DETAIL_TanggalJTP&#34;) = DBNull.Value End If dr(&#34;DETAIL_TipeMotor&#34;) = isiData.detail(j).tipeMotor dr(&#34;DETAIL_Angsuran&#34;) = isiData.detail(j).angsuran dr(&#34;DETAIL_Tenor&#34;) = isiData.detail(j).tenor dr(&#34;DETAIL_Ke&#34;) = isiData.detail(j).ke dr(&#34;DETAIL_StatusFaktur&#34;) = isiData.detail(j).statusFaktur dr(&#34;DETAIL_Plat&#34;) = isiData.detail(j).plat dt.Rows.Add(dr) Next Next If dt.Rows.Count &gt; 0 Then &#39;Bind DataTable to your GridView grdView.DataSource = dt grdView.DataBind() End If End Sub Public Class Infos Public Property error_message() As String Get Return m_error_message End Get Set(value As String) m_error_message = value End Set End Property Private m_error_message As String Public Property [error]() As String Get Return m_error End Get Set(value As String) m_error = value End Set End Property Private m_error As String Private m_detail As List(Of Detail) Public Property detail() As List(Of Detail) Get Return m_detail End Get Set(value As List(Of Detail)) m_detail = value End Set End Property Private m_master As List(Of Master1) Public Property Master() As List(Of Master1) Get Return m_master End Get Set(value As List(Of Master1)) m_master = value End Set End Property End Class Public Class Detail Public Property tanggalBeli() As String Get Return m_tgl_beli End Get Set(value As String) m_tgl_beli = value End Set End Property Private m_tgl_beli As String Public Property tanggalJTP() As String Get Return m_tgl_jtp End Get Set(value As String) m_tgl_jtp = value End Set End Property Private m_tgl_jtp As String Public Property tipeMotor() As String Get Return m_tipe_motor End Get Set(value As String) m_tipe_motor = value End Set End Property Private m_tipe_motor As String Public Property angsuran() As String Get Return m_angsuran End Get Set(value As String) m_angsuran = value End Set End Property Private m_angsuran As String Public Property tenor() As String Get Return m_tenor End Get Set(value As String) m_tenor = value End Set End Property Private m_tenor As String Public Property ke() As String Get Return m_ke End Get Set(value As String) m_ke = value End Set End Property Private m_ke As String Public Property statusFaktur() As String Get Return m_sts_faktur End Get Set(value As String) m_sts_faktur = value End Set End Property Private m_sts_faktur As String Public Property plat() As String Get Return m_plat_no End Get Set(value As String) m_plat_no = value End Set End Property Private m_plat_no As String End Class Private m_NoKTP As String Public Class Master1 Public Property NoKTP() As String Get Return m_master_ktp End Get Set(value As String) m_master_ktp = value End Set End Property Private m_master_ktp As String Public Property Nama() As String Get Return m_master_nama End Get Set(value As String) m_master_nama = value End Set End Property Private m_master_nama As String Public Property AlamatMaster() As String Get Return m_master_alamat End Get Set(value As String) m_master_alamat = value End Set End Property Private m_master_alamat As String End Class </pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <table border="1"> <tbody> <tr> <td><strong>error</strong></td> <td><strong>error_message</strong></td> <td><strong>MASTER_NoKTP</strong></td> <td><strong>MASTER_Nama</strong></td> <td><strong>MASTER_AlamatMaster</strong></td> <td><strong>DETAIL_TanggalBeli</strong></td> <td><strong>DETAIL_TanggalJTP</strong></td> <td><strong>DETAIL_TipeMotor</strong></td> <td><strong>DETAIL_Angsuran</strong></td> <td><strong>DETAIL_Tenor</strong></td> <td><strong>DETAIL_StatusFaktur</strong></td> <td><strong>DETAIL_Ke</strong></td> <td><strong>DETAIL_Plat</strong></td> </tr> <tr> <td>FALSE</td> <td>&nbsp;</td> <td>3202110611900004</td> <td>SUGIRI</td> <td>KP SEKARWANGI</td> <td>8/9/2016 12:00:00 AM</td> <td>&nbsp;</td> <td>REVO</td> <td>573000</td> <td>11</td> <td>BTL</td> <td>0</td> <td>&nbsp;</td> </tr> <tr> <td>FALSE</td> <td>&nbsp;</td> <td>3202110611900004</td> <td>SUGIRI</td> <td>KP SEKARWANGI</td> <td>8/10/2015 12:00:00 AM</td> <td>9/10/2015 12:00:00 AM</td> <td>ABS REVO</td> <td>606000</td> <td>12</td> <td>CLSD</td> <td>12</td> <td>F6631VZ</td> </tr> </tbody> </table> <p>&nbsp;</p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/855546/JSON-data-not-mapping-to-Class-Property-in-VBNet/https://www.aspforums.net:443/Threads/855546/JSON-data-not-mapping-to-Class-Property-in-VBNet/Wed, 20 Dec 2017 02:59:38 GMT