var dataset = {"read_data":[{"date":"2010\/11\/02 03:30:05","value":"2"},
{"date":"2010\/11\/02 03:30:06","value":"1"}]};
var append = {"read_data":[{"date":"2010\/11\/02 03:30:07","value":"3"},
{"date":"2010\/11\/02 03:30:08","value":"4"}]};
I have two data objects like these two. How do I use the JQuery.extend();
to merge them together? so that they look like this so that :
我有两个这样的数据对象。我如何使用JQuery.extend();将它们合并在一起?所以他们看起来像这样:
dataset === {"read_data":[{"date":"2010\/11\/02 03:30:05","value":"2"},
{"date":"2010\/11\/02 03:30:06","value":"1"},
{"date":"2010\/11\/02 03:30:07","value":"3"},
{"date":"2010\/11\/02 03:30:08","value":"4"}]};
All the methods contained in this site is not working at all.
本网站包含的所有方法根本不起作用。
1 个解决方案
#1
7
jQuery.extend overwrites members with same names and does not support array merging. You'll need to do:
jQuery.extend覆盖具有相同名称的成员,不支持数组合并。你需要这样做:
$.merge(dataset.read_data, append.read_data);
#1
7
jQuery.extend overwrites members with same names and does not support array merging. You'll need to do:
jQuery.extend覆盖具有相同名称的成员,不支持数组合并。你需要这样做:
$.merge(dataset.read_data, append.read_data);