I have to iterate through json array object.
It has following structure.
var myJSONObject = {
"abc": {
"prod_1": [
{"prod_ver" : "prod 1 ver 1"},
{"prod_ver" : "prod 1 ver 2"},
],
"prod_2": [
{"prod_ver" : "prod 2 ver 1"},
{"prod_ver" : "prod 2 ver 2"},
],
"prod_3": [
{"prod_ver" : "prod 3 ver 1"},
{"prod_ver" : "prod 3 ver 2"},
]
}
};
Basically what I am doing is prod_1 is name of a product and the list of versions that prod_1 has are populated inside it.
So now what i want is the name of the product as well as what versions it has.
The problem is there can be many products and many versions under that product.
So i need a proper looping structure in javascript that can be generic to handle it.
It would be best if the loop stores product name in one var and it's version in another var as there are some checking i need to on product name.
If the json structure is wrong or a better json structure can be written the please suggest a right/better structure.
Please HELP
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…