Vb.net 解析json文件时出错

Vb.net 解析json文件时出错,vb.net,Vb.net,我试图从一个从web接收的json文件中提取数据。我使用了newtonsoft库 我正在使用以下代码: Dim JSONtxt As String = File.ReadAllText("c:\temp\prova.json") Dim account As Person = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Person)(JSONtxt) 课程为: Public Class Person Public Property

我试图从一个从web接收的json文件中提取数据。我使用了newtonsoft库 我正在使用以下代码:

Dim JSONtxt As String = File.ReadAllText("c:\temp\prova.json")
Dim account As Person = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Person)(JSONtxt)
课程为:

Public Class Person
    Public Property validationType As String
    Public Property lastName As String
    Public Property firstName As String
End Class
不幸的是,帐户没有得到任何值。。。。 怎么可能?? 谢谢你的帮助

这是我的json:

{"listReservationReport":[{"validationType":"PRESENTE","bookingId":"xxxxx","travelId":null,"travelSolutionId":null,"couponId":"xxxxxx","transportMeanName":"aereo","transportClassification":"az","transportMeanDate":"16-01-2020","couponServiceType":"Posto a sedere","materializationType":"NON MATERIALIZZATO","fila":"6","seat":"2A","pnrCode":"xxxxxx","departureLocationName":"NAPOLI capodichino","arrivalLocationName":"ROMA fiumicino","cpCode":"xxxxxxx","offerName":"Super Economy","serviceLevel":"2° Premium","amount":"109,90","adults":1,"teens":0,"alreadyPaied":"--","alreadyCached":"--","ci204":"PRESENTE","firstName":"xxxxxxxx","lastName":"xxxxxx","channelName":"Internet B2C","gender":"Non disponibile","saleSystem":"galileo","travellerInfo":null,"validation":null},{"validationType":"PRESENTE","bookingId":"xxxxx","travelId":null,"travelSolutionId":null,"couponId":"xxxxxx","transportMeanName":"aereo","transportClassification":"az","transportMeanDate":"16-01-2020","couponServiceType":"Posto a sedere","materializationType":"NON MATERIALIZZATO","fila":"6","seat":"2A","pnrCode":"xxxxxx","departureLocationName":"NAPOLI capodichino","arrivalLocationName":"ROMA fiumicino","cpCode":"xxxxxxx","offerName":"Super Economy","serviceLevel":"2° Premium","amount":"109,90","adults":1,"teens":0,"alreadyPaied":"--","alreadyCached":"--","ci204":"PRESENTE","firstName":"xxxxxxxx","lastName":"xxxxxx","channelName":"Internet B2C","gender":"Non disponibile","saleSystem":"galileo","travellerInfo":null,"validation":null},{"validationType":"PRESENTE","bookingId":"xxxxx","travelId":null,"travelSolutionId":null,"couponId":"xxxxxx","transportMeanName":"aereo","transportClassification":"az","transportMeanDate":"16-01-2020","couponServiceType":"Posto a sedere","materializationType":"NON MATERIALIZZATO","fila":"6","seat":"2A","pnrCode":"xxxxxx","departureLocationName":"NAPOLI capodichino","arrivalLocationName":"ROMA fiumicino","cpCode":"xxxxxxx","offerName":"Super Economy","serviceLevel":"2° Premium","amount":"109,90","adults":1,"teens":0,"alreadyPaied":"--","alreadyCached":"--","ci204":"PRESENTE","firstName":"xxxxxxxx","lastName":"xxxxxx","channelName":"Internet B2C","gender":"Non disponibile","saleSystem":"galileo","travellerInfo":null,"validation":null}],"validatorList":[{"firstName":"xxxxx","lastName":"xxxx","roleId":"USR","enterpriseRoleType":"CST"},{"firstName":"xxxx ","lastName":"xxxx ","roleId":"xxx","enterpriseRoleType":"CT"},{"firstName":"x","lastName":"xxxx ","roleId":"USR","enterpriseRoleType":"CPV"},{"firstName":"xxx","lastName":"xxx","roleId":"USR","enterpriseRoleType":"CT"}],"materializedStatus":[{"onboard":30,"absent":0,"none":1,"defect":0,"undo":0}],"notMaterializedStatus":[{"onboard":522,"absent":0,"none":110,"defect":0,"undo":0}]}

好吧,试试这个

Imports System.Linq
Imports BVSoftware.Bvc5.Core
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System.IO
Imports System.Collections.ObjectModel

Partial Class _testPW22
    Inherits System.Web.UI.Page

    Private Class Person
        Public Property validationType As String
        Public Property lastName As String
        Public Property firstName As String
    End Class

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        Dim JSONtxt As String = File.ReadAllText("c:\temp\prova.json")
        Dim ob As JObject = JObject.Parse(JSONtxt)

        Dim persons As New Collection(Of Person)()

        For Each item As JObject In ob.SelectToken("listReservationReport")
            Dim test As Person = JsonConvert.DeserializeObject(Of Person)(item.ToString())
            persons.Add(test)
        Next

    End Sub

End Class

这不是有效的JSON
“validation”:null},]
您遇到了什么错误?帐户没有“nothing”值请尝试使用以查看您的格式是否正确:看起来您有逗号,就像您在使用JArray一样,但其中只有一个对象。