Method 1.Assign the property.
varobjQuotations = {
"vendors":[
{
"strVendor":"V1",
"objQuotation":{"products":
[
{"strProduct":"Soap", "numPrice": "40"},
{"strProduct":"Vanish", "numPrice": "80"},
{"strProduct":"Biscuit", "numPrice": "25"}
]
}
}
]
}
The Productand price information can be accessed like this:
alert("Product: "+objQuotations.vendors[0].objQuotation.products[0].strProduct+"\n"+
"Price:"+objQuotations.vendors[0].objQuotation.products[0].numPrice)
Method 2.Change the project to the array.
var objQuotations = {
"vendors": [
{
"strVendor": "V1",
"objQuotation":
[
{"strProduct": "Soap","numPrice": "40"},
{"strProduct": "Vanish","numPrice": "80"},
{"strProduct": "Biscuit","numPrice": "25"}
]
}
]
}
The Productand price information can be accessed like this:
alert ("Product:"+objQuotations.vendors[0].objQuotation[0].strProduct+"\n"+
"Price:"+objQuotations.vendors[0].objQuotation[0].numPrice);
Comments
Leave a comment