title: How to convert string to array of objects in javascript
body: <p>I want to convert this string to array of objects.</p>
  
  <p>Here is my String</p>
  
  <pre><code>var a = 'SG 925|AMD-MAA|19:15|21:40|SG 703|VNS-BOM|19:45|22:05';
  </code></pre>
  
  <p>I want to convert like this</p>
  
  <pre><code>[
  {'name':'SG 925','place':'AMD-MAA','from':'19:15','to':'21:40'}
  {'name':'SG 703','place':'VNS-BOM','from':'19:45','to':'22:05'}
  ]
  </code></pre>
  
  <p>Here is what i have tried so far</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>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);</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="http://jsfiddle.net/znohcwa3/12/" rel="nofollow noreferrer">Here is my Fiddle</a></p>
  
  <p>How can i do this in javascript?</p>