数组a:[{"user_num":"75925","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75921","MeterNo":"50005445","BookNo":"51010"},{"user_num":"7595","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75984","MeterNo":"50005445","BookNo":"51010"},{"user_num":"759020","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75930","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75911","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75931","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75912","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75932","MeterNo":"50005445","BookNo":"51010"},{"user_num":"75913","MeterNo":"50005445","BookNo":"51010"}]数组b:[{user_num:75925,name:"范小明"},{user_num:75921,name:"李大霄"},{user_num:7595,name:"刘士雨"},{user_num:75984,name:"廖冰"},{user_num:7598020,name:"李刚"},{user_num:7597,name:"李世民"},{user_num:75930,name:"刘彬彬"},{user_num:75911,name:"森美"}]我想得到这样的效果,遍历数组a的user_num,如果,其值在数组b里,则取出该数组b的name属性,并添加到数组a中。如果user_num没有在数组b中,在添加一个默认值name属性(可以设为default)给数组a.最后,数组a将变成这样:[{"user_num":"75925","MeterNo":"50005445","BookNo":"51010","name":"范小明"},{"user_num":"75921","MeterNo":"50005445","BookNo":"51010","name":"李大霄"},{"user_num":"7595","MeterNo":"50005445","BookNo":"51010","name":"刘士雨"},{"user_num":"75984","MeterNo":"50005445","BookNo":"51010","name":"廖冰"},{"user_num":"759020","MeterNo":"50005445","BookNo":"51010","name":"李刚"},{"user_num":"75930","MeterNo":"50005445","BookNo":"51010","name":"刘彬彬"},{"user_num":"75911","MeterNo":"50005445","BookNo":"51010","name":"森美"},{"user_num":"75931","MeterNo":"50005445","BookNo":"51010","name":"default"},{"user_num":"75912","MeterNo":"50005445","BookNo":"51010","name":"default"},{"user_num":"75932","MeterNo":"50005445","BookNo":"51010","name":"default"},{"user_num":"75913","MeterNo":"50005445","BookNo":"51010","name":"default"}]
慕的地10843
慕妹3242003
相关分类