I want to convert this string to array of objects.
Here is my String
var a = 'SG 925|AMD-MAA|19:15|21:40|SG 703|VNS-BOM|19:45|22:05';
I want to convert like this
[
{'name':'SG 925','place':'AMD-MAA','from':'19:15','to':'21:40'}
{'name':'SG 703','place':'VNS-BOM','from':'19:45','to':'22:05'}
]
Here is what i have tried so far
var a = 'SG 925|AMD-MAA|19:15|21:40|SG 703|VNS-BOM|19:45|22:05';
a = a.split("SG ");
a = a.filter(function(e){return e});
console.log(a);
How can i do this in javascript?
SG?SGwhen you split