Ciao a tutti
Sto cercando di deserializzare un file JSON con VB.net Ver 19 e in parte ho fatto, il Testo JSON l'ho scritto in una Textbox ed � questo:
---------------------------------------------------------------------------------------------------------------
[
{
"order_id": "2565d080360c546271fab9e989c22159d9af1089fce5837fb 3a65b977210d909",
"order_type": "sn_booking",
"data": {
"gtin": "08720514402214",
"product_id": null,
"serial_numbers": [ "Yqfer2k7xc7fwSGTtevt", "xXmYz4AaCAAbjqhdh9Y8", "aQFvVzq3bTAJSreAlOxc", "2aq8fsVqtz0qSSbfDWEk", "nd5Ij0rKgZRehgeHZx1C", "D32uQJke0pZYQFmVR6JQ", "TkVk9rZOxfqPV7dEsMxR", "NtJp3Nkf67jPFJNmNPIA", "d61r4TjJuP0qfEMwNyQE", "E5PIDPrgiEPuea48Hy6b" ]
}
},
{
"order_id": "f204aa0b3085d38e242bf8dfcb9c87bff23226d2100cd4a8a bae8e586eb9d1ab",
"order_type": "sn_booking",
"data": {
"gtin": "08720514402184",
"product_id": null,
"serial_numbers": [ "l4VNkml6rVbWpQQKu9pJ", "rzWiVse5Y4zSuPSazjAC", "YSv6B2VoSwGvcouIQG7d", "AgKPQ0Y18PxAxLKhG8cb", "aDniwWZFXS3J7JHIMTgk", "pahjIzBtsSAcpM0EHQxL", "WWuJn8d2fzvIDo162yK3", "wMBesG3BntnB0K4H9FXG", "LW2pE8jow5XIUabF2oOr", "GlmZkcFQXR1wEwfBH9CX" ]
}
}
]
------------------------------------------------------------------------------------------------------------------
La routine che ho realizzato �:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Exit Sub
Dim rawresp As String
rawresp = TextBox2.Text
Dim varses() = Newtonsoft.Json.JsonConvert.DeserializeObject(Of LeggiJson())(rawresp)
end sub
Public Class LeggiJson
Public order_id As String
Public order_type As String
Public Data As Datas
End Class
Public Class Datas
Public gtin As String
Public product_id As String
Public serial_number(10) As String '<- uno dei tanti tentativi di definizione
End Class
La routine funziona fino a "product_id" correttamente ovvero legge le due serie di dati, li inserisce nelle variabili correttamente fino a "product_id" ma da li in poi non legge piu nulla, in pratica non riesco ad estrapolare i dati dopo "serial_number".
Ho tentato di definire "serial_number" in diversi modi, ma non ho capito come costruire l'array relativo.
Chiedo aiuto, Grazie