Get specific Json field with NewtonSoft

Viewed 38

Im using newtonsoft, and I need to get two specific fields on a Json response:

{
    "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"
                }
            }]
        }]
    }]
}

I need to do this on a legacy intranet (VB.NET). I specifically need to get the monthlyPremium field and the id field.

I tried

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")

But I get an error at "deductables" (doesn't exist).

Thanks :)

1 Answers

I've made it work like this:

Money = ser("quoteOptions")(0)("deductables")(0)("quoteOptions")(0)("pricingAndLimits")("monthlyPremium")

Thanks CrlueD

Related