Bonjour,
Pour faire simple...je récupère un jSon d'une machine outil.
Je désérialise ce dernier depuis un fichier texte.
Dim oRootObject As oRoot = JsonConvert.DeserializeObject(Of oRoot)(File.ReadAllText("C:\Tmp\jsonNumHK.txt"))
Le jSon est formé de 3 Objets et une liste d'Objets
Pour récupérer lespropriétés et les valeurs des Objets, aucun problème:
1 2 3 4 5 6 7 8
|
Dim FLAGS As BindingFlags = (BindingFlags.Instance Or BindingFlags.[Static] Or BindingFlags.[Public] Or BindingFlags.NonPublic)
Dim type As Type = GetType(oRoot)
Dim pi As PropertyInfo() = type.GetProperties()
For Each [property] As PropertyInfo In pi
propertyData = [String].Format("Property : {0} " & vbTab & " Type : {1}", [property].Name, [property].PropertyType.Name)
value = [property].GetValue(oRootObject, Nothing)
Next |
Le problème se situe au niveau de la liste d'Objets!
J'arrive bien à récupérer les propriétés, mais pas les "values" concernées...
1 2 3 4 5 6 7 8 9
|
Dim nbrList As Integer = oRootObject.listOData.Count()
Dim arr(nbrList - 1) As Object
pi = GetType(listOData).GetProperties()
For Each el As Object In arr
For Each [prop] As PropertyInfo In pi
Dim outPut as string = ([prop3].Name, [prop3].Name & "(" & [prop3].PropertyType.Name & ")").ToString()
Next
Next |
Je n'arrive pas à utiliser GetValue() avec la liste....
Merci,
Partager