function JSON_merge() { var json = {}, args = arguments, copy = function(f, s) { if (!Object.keys(s).length || f === null) return; for (var i in s) { if (typeof s[i] === ‘object‘ && !!s[i]) { f[i] = s[i].constructor === Array ? [] : {}; copy(f[i], s[i]); } else { f[i] = s[i]; } } return f; }; for (var i in args) { if (!args[i] || args[i].constructor !== Object) throw new Error(‘arguments has issue!‘); copy(json, args[i]); } return json; }
时间: 2024-10-03 12:46:53