I need to iterate through a json array object.
It has the 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'm doing is prod_1 - this is the name of the product and the list of versions that prod_1 is populated inside of it.
So now I want the name of the product, as well as what it had.
The problem is that there can be many products and many versions in this product. Therefore, I need the right loop structure in javascript , which may be common to handle it.
It would be better if the loop stores the product name in one var and its version in another var, as there are some checks that I need for the product name.
If the json structure is incorrect or a better json structure can be written, suggest the correct / best structure.
Please HELP
Thanks in advance.
Saurabh
source share