Reputation: 124
Is there any possible way to convert direct url to json into xml as text into one textbox?
Example:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Json1 as string = "http://pastebin.com/raw.php?i=p3uBzBtm"
Dim jss = New JsonSerializer()
Dim response2 = jss.Deserialize(Of Object)(Json1)
textbox1.text = response2
End Sub
Sorry for this bad example, I'm newbie in this language.
Upvotes: 1
Views: 10542
Reputation: 6251
Use this code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Json1 As String = New WebClient().DownloadString("http://pastebin.com/raw.php?i=p3uBzBtm")
Dim str = JsonConvert.DeserializeXmlNode(Json1)
TextBox1.Text = str.OuterXml
End Sub
For multiple nodes you will want something like this:
Dim Json1 As String = "{ 'root': " & New WebClient().DownloadString("http://pastebin.com/raw.php?i=ugZrw4d6") & " }"
Dim doc As XmlDocument = JsonConvert.DeserializeXmlNode(Json1)
Dim result As String = doc.ChildNodes(0).InnerXml
TextBox1.Text = result
Upvotes: 4