我是靠谱客的博主 风中万宝路,这篇文章主要介绍jQuery实现简单复制json对象和json对象集合操作示例,现在分享给大家,希望可以做个参考。

本文实例讲述了jQuery实现简单复制json对象和json对象集合操作。分享给大家供大家参考,具体如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>www.uoften.com jQuery复制json</title> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript"> $(function () { var classList = [ { classId: 1, className: '一班', students: [ { studentId: 1, studentName: '张三' }, { studentId: 2, studentName: '李四' } ] }, { classId: 2, className: '二班', students: [ { studentId: 3, studentName: '王五' }, { studentId: 4, studentName: '马六' } ] } ] var classDemo = { classId: 1, className: '一班', students: [ { studentId: 1, studentName: '张三' }, { studentId: 2, studentName: '李四' } ] } var newClassList = jQuery.extend(true, [], classList);//复制对象集合 var newClassDemo = jQuery.extend(true, {}, classDemo);//复制对象 //输出测试: console.log(newClassList); console.log(newClassDemo); }); </script> </head> <body> </body> </html>

使用本站HTML/CSS/JS在线运行测试工具:http://tools.uoften.com/code/HtmlJsRun,可得到如下测试运行效果:

PS:关于json操作,这里再为大家推荐几款比较实用的json在线工具供大家参考使用:

在线JSON代码检验、检验、美化、格式化工具:
http://tools.uoften.com/code/json

JSON在线格式化工具:
http://tools.uoften.com/code/jsonformat

在线XML/JSON互相转换工具:
http://tools.uoften.com/code/xmljson

json代码在线格式化/美化/压缩/编辑/转换工具:
http://tools.uoften.com/code/jsoncodeformat

在线json压缩/转义工具:
http://tools.uoften.com/code/json_yasuo_trans

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery操作json数据技巧汇总》、《jQuery常用插件及用法总结》、《jQuery扩展技巧总结》及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。

最后

以上就是风中万宝路最近收集整理的关于jQuery实现简单复制json对象和json对象集合操作示例的全部内容,更多相关jQuery实现简单复制json对象和json对象集合操作示例内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(173)

评论列表共有 0 条评论

立即
投稿
返回
顶部