一个json数据中有100条数据,每一条都需要添加node:node字段,采用递归的方式如何添加该字段。数据格式如下[{"_id":"5a2a251752d3ca6a96a26601","user":"qqq","email":"aaa"},{"_id":"5a2a25b352d3ca6a96a26638","user":"www","email":"bbb"},{"_id":"5a2a260952d3ca6a96a2665a","user":"sss","email":"zzz"}]
2 回答
智慧大石
TA贡献1946条经验 获得超3个赞
letaddValue=function(json,key,value){for(letiinjson){if(typeofjson==="object"){addValue(json[i],key,value);}}json[key]=value;}addValue(json,'node','node');
添加回答
举报
0/150
提交
取消