Hallo!
Also ich hab da so meine Probleme mit meinem typisiertem DataTable!
Ich lese ein JSONString und deserialisiere ihn mittels der generierten Klassen! Klappt auch alles korrekt..
..jedoch bekomme ich es nicht hin von diesem DataTable meine DataGridView zu füllen!
Das ich, wenn ich in meiner Deserialisierungs-Klasse eine List(of String) hab, diese nicht einfach als Combobox darstellen kann enttäuscht mich ein bisschen!
Wie bewerkstelligt Ihr solche Umwandlungen?
Ich hatte das mal irgend wie geschafft das ich im DataTable das betreffende Feld als Object deklariert hab..und dann dieses Object zum füllen der Combobox verwendet hab..
..aber iwie komm ich nich auf den richtigen Trichter!
Also wie kann ich mein JSON das viele List(of) enthält am besten in nem DataGridview mit Comboboxen darstellen?!?
Mach ich das am besten ohne DataTables?
Spoiler anzeigen
Also ich hab da so meine Probleme mit meinem typisiertem DataTable!
Ich lese ein JSONString und deserialisiere ihn mittels der generierten Klassen! Klappt auch alles korrekt..
..jedoch bekomme ich es nicht hin von diesem DataTable meine DataGridView zu füllen!
Das ich, wenn ich in meiner Deserialisierungs-Klasse eine List(of String) hab, diese nicht einfach als Combobox darstellen kann enttäuscht mich ein bisschen!
Wie bewerkstelligt Ihr solche Umwandlungen?
Ich hatte das mal irgend wie geschafft das ich im DataTable das betreffende Feld als Object deklariert hab..und dann dieses Object zum füllen der Combobox verwendet hab..
..aber iwie komm ich nich auf den richtigen Trichter!
Also wie kann ich mein JSON das viele List(of) enthält am besten in nem DataGridview mit Comboboxen darstellen?!?
Mach ich das am besten ohne DataTables?
VB.NET-Quellcode
- Public Class Artist
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("id")> ByVal id As String,
- <JsonProperty("name")> ByVal name As String)
- Me.Id = id
- Me.Name = name
- End Sub
- <JsonProperty("id")>
- Public ReadOnly Id As String
- <JsonProperty("name")>
- Public ReadOnly Name As String
- End Class
- Public Class _Date
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("year")> ByVal year As Integer,
- <JsonProperty("day")> ByVal day As Integer,
- <JsonProperty("month")> ByVal month As Integer)
- Me.Year = year
- Me.Day = day
- Me.Month = month
- End Sub
- <JsonProperty("year")>
- Public ReadOnly Year As Integer
- <JsonProperty("day")>
- Public ReadOnly Day As Integer
- <JsonProperty("month")>
- Public ReadOnly Month As Integer
- End Class
- Public Class Track
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("artists")> ByVal artists As List(Of Artist),
- <JsonProperty("id")> ByVal id As String,
- <JsonProperty("position")> ByVal position As Integer,
- <JsonProperty("title")> ByVal title As String)
- Me.Artists = artists
- Me.Id = id
- Me.Position = position
- Me.Title = title
- End Sub
- <JsonProperty("artists")>
- Public ReadOnly Artists As List(Of Artist)
- <JsonProperty("id")>
- Public ReadOnly Id As String
- <JsonProperty("position")>
- Public ReadOnly Position As Integer
- <JsonProperty("title")>
- Public ReadOnly Title As String
- End Class
- Public Class Medium
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("format")> ByVal format As String,
- <JsonProperty("position")> ByVal position As Integer,
- <JsonProperty("track_count")> ByVal trackCount As Integer,
- <JsonProperty("tracks")> ByVal tracks As List(Of Track),
- <JsonProperty("title")> ByVal title As String)
- Me.Format = format
- Me.Position = position
- Me.TrackCount = trackCount
- Me.Tracks = tracks
- Me.Title = title
- End Sub
- <JsonProperty("format")>
- Public ReadOnly Format As String
- <JsonProperty("position")>
- Public ReadOnly Position As Integer
- <JsonProperty("track_count")>
- Public ReadOnly TrackCount As Integer
- <JsonProperty("tracks")>
- Public ReadOnly Tracks As List(Of Track)
- <JsonProperty("title")>
- Public ReadOnly Title As String
- End Class
- Public Class Releaseevent
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("country")> ByVal country As String,
- <JsonProperty("date")> ByVal _date As _Date)
- Me.Country = country
- Me._Date = _date
- End Sub
- <JsonProperty("country")>
- Public ReadOnly Country As String
- <JsonProperty("date")>
- Public ReadOnly _Date As _Date
- End Class
- Public Class Release
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("artists")> ByVal artists As List(Of Artist),
- <JsonProperty("country")> ByVal country As String,
- <JsonProperty("date")> ByVal _date As _Date,
- <JsonProperty("id")> ByVal id As String,
- <JsonProperty("medium_count")> ByVal mediumCount As Integer,
- <JsonProperty("mediums")> ByVal mediums As List(Of Medium),
- <JsonProperty("releaseevents")> ByVal releaseevents As List(Of Releaseevent),
- <JsonProperty("title")> ByVal title As String,
- <JsonProperty("track_count")> ByVal trackCount As Integer)
- Me.Artists = artists
- Me.Country = country
- Me._Date = _date
- Me.Id = id
- Me.MediumCount = mediumCount
- Me.Mediums = mediums
- Me.Releaseevents = releaseevents
- Me.Title = title
- Me.TrackCount = trackCount
- End Sub
- <JsonProperty("artists")>
- Public ReadOnly Artists As List(Of Artist)
- <JsonProperty("country")>
- Public ReadOnly Country As String
- <JsonProperty("date")>
- Public ReadOnly _Date As _Date
- <JsonProperty("id")>
- Public ReadOnly Id As String
- <JsonProperty("medium_count")>
- Public ReadOnly MediumCount As Integer
- <JsonProperty("mediums")>
- Public ReadOnly Mediums As List(Of Medium)
- <JsonProperty("releaseevents")>
- Public ReadOnly Releaseevents As List(Of Releaseevent)
- <JsonProperty("title")>
- Public ReadOnly Title As String
- <JsonProperty("track_count")>
- Public ReadOnly TrackCount As Integer
- End Class
- Public Class Releasegroup
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("artists")> ByVal artists As List(Of Artist),
- <JsonProperty("id")> ByVal id As String,
- <JsonProperty("releases")> ByVal releases As List(Of Release),
- <JsonProperty("title")> ByVal title As String,
- <JsonProperty("secondarytypes")> ByVal secondarytypes As List(Of String),
- <JsonProperty("type")> ByVal type As String)
- Me.Artists = artists
- Me.Id = id
- Me.Releases = releases
- Me.Title = title
- Me.Secondarytypes = secondarytypes
- Me.Type = type
- End Sub
- <JsonProperty("artists")>
- Public ReadOnly Artists As List(Of Artist)
- <JsonProperty("id")>
- Public ReadOnly Id As String
- <JsonProperty("releases")>
- Public ReadOnly Releases As List(Of Release)
- <JsonProperty("title")>
- Public ReadOnly Title As String
- <JsonProperty("secondarytypes")>
- Public ReadOnly Secondarytypes As List(Of String)
- <JsonProperty("type")>
- Public ReadOnly Type As String
- End Class
- Public Class Recording
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("artists")> ByVal artists As List(Of Artist),
- <JsonProperty("duration")> ByVal duration As Integer,
- <JsonProperty("id")> ByVal id As String,
- <JsonProperty("releasegroups")> ByVal releasegroups As List(Of Releasegroup),
- <JsonProperty("title")> ByVal title As String)
- Me.Artists = artists
- Me.Duration = duration
- Me.Id = id
- Me.Releasegroups = releasegroups
- Me.Title = title
- End Sub
- <JsonProperty("artists")>
- Public ReadOnly Artists As List(Of Artist)
- <JsonProperty("duration")>
- Public ReadOnly Duration As Integer
- <JsonProperty("id")>
- Public ReadOnly Id As String
- <JsonProperty("releasegroups")>
- Public ReadOnly Releasegroups As List(Of Releasegroup)
- <JsonProperty("title")>
- Public ReadOnly Title As String
- End Class
- Public Class Result
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("id")> ByVal id As String,
- <JsonProperty("recordings")> ByVal recordings As List(Of Recording),
- <JsonProperty("score")> ByVal score As Double)
- Me.Id = id
- Me.Recordings = recordings
- Me.Score = score
- End Sub
- <JsonProperty("id")>
- Public ReadOnly Id As String
- <JsonProperty("recordings")>
- Public ReadOnly Recordings As List(Of Recording)
- <JsonProperty("score")>
- Public ReadOnly Score As Double
- End Class
- Public Class Root
- <JsonConstructor>
- Public Sub New(
- <JsonProperty("results")> ByVal results As List(Of Result),
- <JsonProperty("status")> ByVal status As String)
- Me.Results = results
- Me.Status = status
- End Sub
- <JsonProperty("results")>
- Public ReadOnly Results As List(Of Result)
- <JsonProperty("status")>
- Public ReadOnly Status As String
- End Class
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Morrison“ ()