Array 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"
{"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"},
{ "MeterNo": "50005445", "BookNo": "51010"},
{"user_num": "75932", "MeterNo": "50005445", "BookNo": "51010"},
{"user_num": "75913", "MeterNo": "50005445", "BookNo": "51010"}
]
array 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:""}
]
I want the effect of traversing the user_num, of array an if its value is in array b, then take out the name property of array b and add it to array a. If user_num is not in array b, add a default value name attribute (which can be set to default) to the array a.
finally, The array a will look like this:
{"user_num": "75925", "MeterNo": "50005445", "BookNo": "51010", "name": "Fan Xiaoming"},
{"user_num": "75921", "MeterNo": "50005445", "BookNo": "51010", "name": "Li Daxiao"},
{"user_num": "7595", "MeterNo": "50005445", "BookNo": "51010", "name"
{"user_num": "75984", "MeterNo": "50005445", "BookNo": "51010", "name": "Liao Bing"},
{"user_num": "759020", "MeterNo": "50005445", "BookNo": "51010", "name": "Li Gang"},
{"user_num": "75930", "MeterNo": "50005445", "BookNo": "51010", "name": "Liu Binbin"},
{" "MeterNo": "50005445", "BookNo": "51010", "name": "Sammy"},
{"user_num": "75931", "MeterNo": "50005445", "BookNo": "51010", "name": "default"},
{"user_num": "75912", "MeterNo": "50005445", "BookNo": "51010", "name": "default"},
{"user_num": "75932", "MeterNo": "50005445", "name": "default"},
{"user_num": "75913", "MeterNo": "50005445", "BookNo": "51010", "name": "default"}
]