Hallo liebes Forum !
Ich habe da ein kleines Problem mit dem Auslesen meiner JSon Datei, und ich hoffe das mir jemand dabei helfen kann.
Ich habe es geschafft, das das Programm auf die Json-Datei zugreift.
Auch habe ich es geschafft, das ich etwas daraus in ein Label schreiben kann.
Hier ist jedoch das Problem, das das Programm nur die letzten Einträge ausliest und sobald ich was von der Mitte oder vom Anfang lesen möchte ist das Label leer? Und ja es steht auch was drinnen
Hier ist der Code:
Ich hoffe das mir jemand weiterhelfen kann/will.
Ps: Das ist nur zum Testen also nicht das Fertige Programm, deswegen habe ich noch das Label mit Label stehen
Ich habe da ein kleines Problem mit dem Auslesen meiner JSon Datei, und ich hoffe das mir jemand dabei helfen kann.
Ich habe es geschafft, das das Programm auf die Json-Datei zugreift.
Auch habe ich es geschafft, das ich etwas daraus in ein Label schreiben kann.
Hier ist jedoch das Problem, das das Programm nur die letzten Einträge ausliest und sobald ich was von der Mitte oder vom Anfang lesen möchte ist das Label leer? Und ja es steht auch was drinnen
Hier ist der Code:
C#-Quellcode
- Imports System.Net
- Imports System.IO
- Imports System.Linq
- Imports Newtonsoft.Json
- Imports Newtonsoft.Json.Linq
- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim request As HttpWebRequest
- Dim response As HttpWebResponse = Nothing
- Dim reader As StreamReader
- Try
- request = DirectCast(WebRequest.Create("HIER IST MEINE ADRESSE ZUR URL"), HttpWebRequest)
- response = DirectCast(request.GetResponse(), HttpWebResponse)
- reader = New StreamReader(response.GetResponseStream())
- Dim rawresp As String
- rawresp = reader.ReadToEnd
- Dim jResult As JObject = JObject.Parse(rawresp)
- Dim result As List(Of JToken) = jResult.Children().ToList()
- For Each item As JProperty In result
- item.CreateReader()
- Label1.Text = item.Value("TEST3") ' Das wird ausgelesen
- Label2.Text = item.Value("TEST1") ' Das wird NICHT ausgelesen | Macht auch nichts wenn ich es am anfang schreibe
- Next
- Catch ex As Exception
- MsgBox(ex.ToString)
- Finally
- If Not response Is Nothing Then response.Close()
- End Try
- End Sub
- End Class
Ich hoffe das mir jemand weiterhelfen kann/will.
Ps: Das ist nur zum Testen also nicht das Fertige Programm, deswegen habe ich noch das Label mit Label stehen