[英]Deserialize JSON VB.NET
我在使用 VB.NET 反序列化 JSON 時遇到了一個大問題,這里是 json 示例:
[{"id":"1","numerTel":"48123123123","pozostalo":"50","reffer":"","email":""},{"id":"2","numerTel":"48123123123","pozostalo":"10","reffer":"","email":""}]
這是由 mysql select * 查詢生成的 json,我的 vb 應用程序連接到 php 腳本,該腳本返回帶有數據的 json 數組。 我如何反序列化它並使用每一行,我想解析每一行。 這是我在 vb 中的實際代碼:
Dim jsonResponse As String = "[{""id"":""1"",""numerTel"":""48123123123"",""pozostalo"":""50"",""reffer"":"""",""email"":""""},{""id"":""2"",""numerTel"":""48123123123"",""pozostalo"":""10"",""reffer"":"""",""email"":""""}]"
Dim aba As MyC = JsonHelper.JsonDeserialize(Of MyC)(jsonResponse)
和班級:
Public Class MyC
Public Property id() As String
Get
Return m_id
End Get
Set
m_id = Value
End Set
End Property
Private m_id As String
Public Property numerTel() As String
Get
Return m_numerTel
End Get
Set
m_numerTel = Value
End Set
End Property
Private m_numerTel As String
Public Property pozostalo() As String
Get
Return m_pozostalo
End Get
Set
m_pozostalo = Value
End Set
End Property
Private m_pozostalo As String
Public Property reffer() As String
Get
Return m_reffer
End Get
Set
m_reffer = Value
End Set
End Property
Private m_reffer As String
Public Property email() As String
Get
Return m_email
End Get
Set
m_email = Value
End Set
End Property
Private m_email As String
End Class
感謝幫助!
該 JSON 不代表MyC
的實例。 它代表List(Of MyC)
一個實例(或任何可枚舉的集合,真的)。
Dim aba As List(Of MyC) = JsonHelper.JsonDeserialize(Of List(Of MyC))(jsonResponse)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.