0

is there possible to convert this string to array or object? It is not a valid stringify JSON data, not sure how to tackle this.

"{"subject":"Test Comment"},{"message":"Test Message."}"

Thank in advance!

Theren
  • 383
  • 1
  • 3
  • 9
  • 7
    Although I'm sure you'll get answers on how to hack around it below, the best choice will always be to fix it at source - where it is generated – Paul S. Apr 29 '15 at 16:18
  • possible duplicate of [Best way to convert string to array of object in javascript?](http://stackoverflow.com/questions/3473639/best-way-to-convert-string-to-array-of-object-in-javascript) – vjdhama Apr 29 '15 at 16:19
  • 1
    @Paul S. Actually, I am pulling out the data from a LMS service using the API provided which I can't go in and modify the source, what I can do is modify it once I get the data populated on my side. – Theren Apr 30 '15 at 06:11
  • @vjdhama I actually tried the solution on this thread before but it din't solve my problem though. – Theren Apr 30 '15 at 06:15

1 Answers1

2

Like this:

JSON.parse('[' + '{"subject":"Test Comment"},{"message":"Test Message."}' + ']')
CD..
  • 72,281
  • 25
  • 154
  • 163