I sequentially collect information from forms into such arrays:
list = {"name" : "John", "email" : " name@domain.com ", "country" : "Canada", "color" : "blue"}; identifier = "first_round"; list = {"name" : "Harry", "email" : " othername@domain.com ", "country" : "Germany"}; identifier = "second_round";
I want to combine them into something (I can have brackets where I need brackets), for example:
list_all = { "first_round" : {"name" : "John", "email" : " name@domain.com ", "country" : "Canada", "color" : "blue"} , "second_round" : {"name" : "Harry", "email" : " othername@domain.com ", "country" : "Germany"} };
so I can access them, for example:
alert(list_all.first_round.name) -> John
(Note: the name values ("name", "email address", "color") in the two list arrays are not exactly the same, the number of elements in each array list is limited, but it is not known in advance, I need to add only one array in sequence the previous structure each round, and there can be any number of rounds, that is, the "third round": {...}, the "fourth round": {...} and so on.)
Ultimately, I would like it to be well versed in JSON.
I am using jquery library if this helps.