JSON.stringify two objects.
Hi, I have two array objects:
- pupil = new Array(5);
- for(n=0; n<=5; n++){
- pupil[n] = new Object();
- pupil[n].name = "Pupil "+n;
- pupil[n].age = 20+n;
- }
The second object is as follows;
- subjects = new Array(3);
- for(n=0; n<=2; n++){
- subjects[n] = new Object();
- subjects[n].book = "English";
- subjects[n].isbn = 1230
- }
I plan to write this to a file. I can do this with one object array and it works fine but is it possible to write both with something like this?
- details = JSON.stringify(pupil) + JSON.stringify(subjects);
Thanks in advance.