javascript 数组的使用 + js 对象 转换为json 字符串
2015-04-22 21:48
1231 查看
<pre class="javascript" name="code"><script type="text/javascript"> Student.prototype={ id:null, name:null, sex:null, age:null, show:function (){ //类对象的方法,使用属性时必须使用 this alert("id:" + this.id +",name:" + this.name + ",sex:" + this.sex + ",age:" + this.age); } }; function Student(){ //构造函数,必须有 } //创建对象的方式 var student = new Student(); student.id = 1001; student.name = "zhangsan"; student.sex = "20"; student.age = 10; student.show(); <span style="white-space:pre"> </span>//1. 创建数组 <span> </span>var studentArray = new Array(); <span> </span> <span> </span>//2. 数组中添加元素 <span> </span>studentArray.push(student); <span> </span>studentArray.push(student); <span> </span>studentArray.push(student);
<span style="white-space:pre"> </span>//3. 数组移除第一个元素,并返回该元素
<span style="white-space:pre"> </span>var delStu = studentArray.pop();<span> </span><span> </span>//3. 数组对象转换成json 字符串<span> </span>var jsonstr = JSON.stringify(studentArray);
</script>
相关文章推荐
- javascript将一对象(包括数组、JSON、function)转换成字符串
- javascript数据(对象字符串等)转换成json数据的javascript扩展包的使用
- 后台将对象转换为json格式,前台js解析json数据,将字符串转化为数组
- JS中json字符串和json对象之间的转换,PHP中json字符串和php数组之间的转换
- javascript-对象、数组转换为json字符串
- js将js数组或者对象转换成json字符串
- json对象、json格式字符串、java对象【使用此net.sf.json.JSONObject将java对象[比如数组集合Map、Map扩展]转换成json格式字符串】
- JSON(二)——JavaScript中js对象与JSON格式字符串的相互转换
- 详解JavaScript中js对象与JSON格式字符串的相互转换
- Android使用Google Gson实现JSON字符串和对象、对象数组之间相互转换
- 对象和JSON之间的转换?对象集合和字符串之间的转换?在JSP中使用JSNO?
- JavaScript 将 JSON 字符串转换成 JSON 对象的数组
- 把json格式的字符串转换成javascript对象或数组的方法总结
- json的作用:按规定格式保存js语言中的一组数据并转换为字符串(json是种特殊的容器,一般保存对象和数组数据(可以嵌套),并把它们装换为字符串在网络中传输?))
- juicer高效、轻量的前端 (Javascript) 模板引擎的应用与 js-json格式转换为数组
- js传数组到java后台使用Json转换 (高德地图多边形覆盖物显示)
- js 将json字符串转换为json对象的方法解析
- js 将json字符串转换为json对象的方法解析
- 【JS】jQuery中将数组转换成字符串join()和push()使用
- 非标准json,标准json,json字符串与js对象,Java对象之间的相互转换