使用NewtonSoft获取特定的Json字段
我正在使用newtonsoft,我需要在Json响应上获得两个特定字段:使用NewtonSoft获取特定的Json字段,json,vb.net,json.net,Json,Vb.net,Json.net,我正在使用newtonsoft,我需要在Json响应上获得两个特定字段: { "id": "1233323", "quoteOptions": [{ "copay": "20%", "deductables": [{ "deductable": "$250",
{
"id": "1233323",
"quoteOptions": [{
"copay": "20%",
"deductables": [{
"deductable": "$250",
"quoteOptions": [{
"pricingAndLimits": {
"reimbursement": "80%",
"copay": "20%",
"deductable": "$250",
"limit": "$4,000",
"annualPremium": "$413.00",
"monthlyPremium": "$34.00"
}
}]
}]
}]
}
我需要在传统的内部网(VB.NET)上执行此操作。我特别需要得到monthlyPremium字段和id字段
我试过了
Dim json As String = Result
Dim ser As JObject = JObject.Parse(json)
Dim data As List(Of JToken) = ser.Children().ToList
Dim output As String = ""
Dim Premium As String = ser("quoteOptions")("deductables")("quoteOptions")("pricingAndLimits")("monthlyPremium")
但我在“可推断的”(不存在)中得到一个错误
谢谢:)我让它像这样工作:
Money = ser("quoteOptions")(0)("deductables")(0)("quoteOptions")(0)("pricingAndLimits")("monthlyPremium")
感谢CrlueD请在示例中包含实际的JSON字符串,而不是您认为它是什么。您好,Drew,JSON字符串就在postAccessed JArray值的开头,键值无效:“deductables”。应为Int32数组索引。这就是我得到的错误当你看到[]时,它意味着你必须输入[number]。所以,ser(“quoteOptions”)[0]…我用(“deductables”)[0],(“deductables”[0])试过了,但仍然不起作用。