function clone(jsonObj) {
var buf;
if (jsonObj instanceof Array) {
buf = [];
var i = jsonObj.length;
while (i--) {
buf[i] = clone(jsonObj[i]);
}
return buf;
}else if (jsonObj instanceof Object){
buf = {};
for ( var k in jsonObj) {
buf[k] = clone(jsonObj[k]);
}
return buf;
}else {
return jsonObj;
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dz45693/archive/2009/12/22/5057876.aspx