Newtonsoft.Json.JsonReaderException类太分层?

时间:2016-10-18 19:46:04

标签: vb.net json.net response

当我尝试反序列化以下JSON时,我收到错误。

将其复制到TextBox2.text:

{
    “code” : 200,
    “message" : "success",
    “version" : “2",
    “basket” : 
    {
        “total”: “9.23”,
        “subTotal” : “8.45”,
        “currency” : “USD”,
        “discounts” : [
            {
                “product_id” : 1,
                “description”: “Bud Light 6-pack”,
                “UPC” : “23423423423”,
                “quantity” : 1,
                “price” : “-0.45”
            }
        ]
    }
}

这是我的代码:

Public Class JSON_resultMktBasket
    'This is the response from the mkt basket   - /v2/transaction/transaction_id
    Public code As String
    Public message As String
    Public version As String
    Public basket As mktBasket

End Class

Public Class mktBasket
    'Used by JSON_resultMktBasket
    Public total As String
    Public subtotal As String
    Public currency As String
    Public discounts As ProductDiscounts()

End Class

Public Class ProductDiscounts
    'Used by JSON_resultMktBasket
    Public product_id As String
    Public description As String
    Public UPC As String
    Public quantity As String
    Public price As String
End Class

Private Sub btnMktBasketResponse_Click(sender As Object, e As EventArgs) Handles btnMktBasketResponse.Click
    'this is for reading the response when it comes back from the intial store call
    Dim obj2 As JSON_resultMktBasket
    MsgBox(Me.TextBox2.Text)
    'Following line is where i get the exception.......
    obj2 = JsonConvert.DeserializeObject(Of JSON_resultMktBasket)(Me.TextBox2.Text)
End Sub

我收到此错误:

  

Newtonsoft.Json.dll中发生未处理的“Newtonsoft.Json.JsonReaderException”类型异常   附加信息:无效的属性标识符:“。路径'',第2行,位置0.

这是因为我有一个包含其他2层深度课程的课程吗?我真的不知道怎么解决这个问题。

0 个答案:

没有答案