如何用javascript定义对象数组,我要把对象数组转成json传到后台,
varstudent=newObject();student.name="Lanny";student.age="25";student.location="China"...
var student = new Object();
student.name = "Lanny";
student.age = "25";
student.location = "China";
var json = JSON.stringify(student);
我如何定义一个数组,数组每个元素的数据类型是student?? 展开
student.name = "Lanny";
student.age = "25";
student.location = "China";
var json = JSON.stringify(student);
我如何定义一个数组,数组每个元素的数据类型是student?? 展开
3个回答
展开全部
var students = [];
students[students.length] = new Object();
students[students.length] .name = "Lanny";
students[students.length] .age = "25";
students[students.length] .location = "China";
var json = JSON.stringify(students);
var student = new Object();
student.name = "Lanny";
student.age = "25";
student.location = "China";
students = (students || []).push(student);
var json = JSON.stringify(students);
students[students.length] = new Object();
students[students.length] .name = "Lanny";
students[students.length] .age = "25";
students[students.length] .location = "China";
var json = JSON.stringify(students);
var student = new Object();
student.name = "Lanny";
student.age = "25";
student.location = "China";
students = (students || []).push(student);
var json = JSON.stringify(students);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询