0

I need to convert this string into a an array into the format shown below.

itemString


[{"_id":"1e12345","a":"abc","b":def","c":ghi"},{"_id":"1e678910","a":"xzx","b":sed","c":ert"}]

var item=itemString.split("},{").map(function(i){
    return i
})
console.log(item)

what i need to get from from console.log(item)

0:{_id:"1e12345",a:"abc",b:"def",c:"ghi"}
1:{_id:"1e678910",a:"xzx",b:"sed",c:"ert"}

what i get from console.log(item)

0:"[{"_id":"1e12345","a":"abc","b":"def","c":"ghi""
1:""_id":"1e678910","a":"xzx","b":"sed","c":"ert"}]"
JayG
  • 1
  • 1
  • 1
  • 2
  • 6
    Are you looking for [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)? – cbr Jan 31 '20 at 00:51
  • perfect - thanks - exactly what i wanted- happy friday – JayG Jan 31 '20 at 01:10

0 Answers0