1 pièce(s) jointe(s)
Comment parcourir un Objet Newtonsoft.Json.Linq.JObject
Bonjour à tous,
je chargé un fichier JSon où "Courses" correspond au chemin d'accès de mon fichier :
Code:
JsonCourse = JsonConvert.DeserializeObject(File.ReadAllText(Courses))
et je souhaiterai parcourir cet objet pour retrouver mes petits ...
en VBA je sais faire avec JsonConverter, mais en VB je sèche.
VBA :
Code:
1 2 3 4 5 6
| Set JsonCheval = JsonConverter.ParseJson(ligne)
For Numero = 1 to Partants
PartantOuiNon = JsonCheval("participants")(Numero)("statut")
CotePMU = CSng(JsonCheval("participants")(Numero)("dernierRapportDirect")("rapport"))
Next Numero |
Je mets le fichier JSon zippé que je souhaite interroger en pièce jointe.
D'avance merci de votre aide.
Tchicken.
Un collègue m'a trouvé la solution
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Dim jsonCourse As JObject
Dim participants As JToken
jsonCourse = JObject.Parse(File.ReadAllText(Courses))
participants = jsonCourse.GetValue("participants")
For Each participant As JToken In participants
if participant.SelectToken("statut").ToString = "PARTANT" Then
CotePMU = CSng(participant.SelectToken("dernierRapportDirect").SelectToken("rapport").ToString)
Else
CotePMU = 0
End If
Next |