I want to split a string using a comma and need to populate an array of JSON. I have the following string data
const test='00000001,name1,00000002,name2,00000003,name3,00000004,name4';
console.log(test.split('/[\n,|]/',2));
Output : ['00000001','name1','00000002','name2','00000003','name3','00000004','name4']
But I need output like this
[{id:'00000001',name:'name1'},{id:'00000002',name:'name2'},{id:'00000003',name:'name3'},{id:'00000004',name:'name4'}]