来自getir.json的json数据
{"name":"muro","id":"1","firma_adi":"hizli.mobi","link":"http:\/\/www.porn.com","text":"mobil adult porn"}
{"name":"muro","id":"1","firma_adi":"rek.mobi","link":"http:\/\/www.redtube.com","text":"mobil adult porn"}
{"name":"muro","id":"1","firma_adi":"mobil.list","link":"http:\/\/www.youporn.com","text":"mobil adult porn"}
vb.net json拆分使用但问题是这个
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("reklamatik/?uye=1")
Dim ser As New System.Web.Script.Serialization.JavaScriptSerializer
Dim results As JSON_resultArray = DirectCast(ser.Deserialize(Of JSON_resultArray)(result), JSON_resultArray)
Console.WriteLine(results.Vars(1).name)
类
Public Class JSON_result
Public name As String
End Class
Public Class JSON_resultArray
Public Vars() As JSON_result
End Class
没有使用多json数据
这个屏幕来自我的电脑vb 2012工作室
答案 0 :(得分:0)
您的JSON无效,请使用有效的JSON,您应该执行此类操作
<强> VB 强>
Dim data = "[{""name"":""muro"",""id"":""1"",""firma_adi"":""hizli.mobi"",""link"":""http:\/\/www.porn.com"",""text"":""mobil adult porn""}," & vbCr & vbLf & " {""name"":""muro"",""id"":""1"",""firma_adi"":""rek.mobi"",""link"":""http:\/\/www.redtube.com"",""text"":""mobil adult porn""}," & vbCr & vbLf & " {""name"":""muro"",""id"":""1"",""firma_adi"":""mobil.list"",""link"":""http:\/\/www.youporn.com"",""text"":""mobil adult porn""}]"
Dim ser = New System.Web.Script.Serialization.JavaScriptSerializer()
Dim p = ser.Deserialize(Of List(Of JsonItem))(data)
映射JSON元素的类:
Public Class JsonItem
Public Property name As String
Public Property id As String
Public Property firma_adi As String
Public Property link As String
Public Property text As String
End Class
<强> C#强>
var data = @"[{""name"":""muro"",""id"":""1"",""firma_adi"":""hizli.mobi"",""link"":""http:\/\/www.porn.com"",""text"":""mobil adult porn""},
{""name"":""muro"",""id"":""1"",""firma_adi"":""rek.mobi"",""link"":""http:\/\/www.redtube.com"",""text"":""mobil adult porn""},
{""name"":""muro"",""id"":""1"",""firma_adi"":""mobil.list"",""link"":""http:\/\/www.youporn.com"",""text"":""mobil adult porn""}]";
var ser = new System.Web.Script.Serialization.JavaScriptSerializer();
var p = ser.Deserialize<List<JsonItem>>(data);
映射JSON元素的类:
public class JsonItem
{
public string name { get; set; }
public string id { get; set; }
public string firma_adi { get; set; }
public string link { get; set; }
public string text { get; set; }
}