Closed stevecuzcousins closed 3 years ago
Hi
That would be: Response.Write oJSON.data("address").item("streetAddress")
I've also added this to the example.
Cheers
Thank you but what would I write for an item in a few more levels of depth
My JSON file is
"VehicleResults" "FinanceProductResults" "Quote" "Term"
Thank you
@stevecuzcousins I can't see your json. could you please place that within code
tags?
I hadn't added it just the key names but I'll paste a little of it below with some information redacted
`
| "VehicleResults": [ | { | "FinanceProductResults": [ | { | "Key": "***", | "HasError": false, | "Notifications": { | "Public": [] | }, | "Quote": { | "AllInclusiveRegularPayment": 373.35, | "CashPrice": 24000.0, | "TotalPrice": 24000.0, | "TotalDeposit": 5000.00, | "Deposit": 5000.00, | "Balance": 19000.00, | "Term": 60,
`
@stevecuzcousins How to get the value is very much dependent on how structure of the Json. Like object, arrays. To loop all the items in the arrays you should do something like:
For Each VehicleResult In oJSON.data("VehicleResults")
Set thisVehicleResult = oJSON.data("VehicleResults").item(VehicleResults)
For Each FinanceProductResult In thisVehicleResult.item("FinanceProductResults")
Set thisFinanceProductResult = thisVehicleResult.item("FinanceProductResults").item(FinanceProductResult)
Response.Write thisFinanceProductResult.item("Quote").item("Term")
Next
Next
If you're sure you are only interested in the first items on the arrays:
oJSON.data("VehicleResults")(0).item("FinanceProductResults")(0).item("Quote").item("Term")
Thank you, i have it working in another language but wanted to get a solution with classic asp to save me rewriting for a one-off fix. It's actually very similar to javascript code that I have used elsewhere but I just couldn't get the exact syntax. It was myArr.VehicleResults[0].FinanceProductResults[0].Quote.Term
In your basic example you have
oJSON.data("firstName")
How would you get the data in say city which is part of address
The JSON file I am working with has many more levels but if I can see the correct syntax for your example then I should be able to work it out
Thanks