Convert string to array or object

2020-05-04 13:55发布

问题:

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!

回答1:

Like this:

JSON.parse('[' + '{"subject":"Test Comment"},{"message":"Test Message."}' + ']')