解码JSON(String) - visual basic

时间:2013-08-15 20:46:51

标签: json vb.net

如何在Visual Basic中解码JSON字符串(无下载程序)

Private Sub ViewHintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewHintToolStripMenuItem.Click
    Dim instance As Net.WebClient = New Net.WebClient
    Dim address As String = "https://pr2hub.com/files/artifact_hint.txt"
    Dim returnValue As String
    returnValue = instance.DownloadString(address)
    Artifact.Text = returnValue
    HintText.Show()
    HintText.RichTextBox1.Text = returnValue
    HintText.RichTextBox2.Text = returnValue
End Sub

1 个答案:

答案 0 :(得分:0)

通过解码我假设你的意思是反序列化。你试过System.Web.Script.Serialization.JavaScriptSerializer吗?

我不明白你在上面尝试反序列化的内容,但这是一个通用的例子:

Dim s as String = "{ 'name':'Fred', 'address':'123 Main', 'phone':'333-4444'}"
Dim jss As New JavaScriptSerializer
Dim o As Object = jss.Deserialize(Of Object)(s)

注意还有一个jss.Serialize方法可用。