After receiving a HTTP response, I am faced with the challenge of working with the following variable:
let data = '[{name: "John"}, {name: "Alice"}, {name: "Lily"}]'
Although there are more objects with additional properties, this snippet provides a glimpse of the data structure.
Upon attempting to use JSON.parse(data)
, an error is thrown:
[{name: "John"}, {name: "Alice"}, {name: "Lily"}]
^
SyntaxError: Unexpected token n
What approach should I take in order to successfully parse this string into an array of JavaScript objects?