0
let origin = "[{'a':1, 'b':2}, {'a':3, 'b':4}, {'a':5, 'b':6}]"

let output = [{'a':1, 'b':2}, {'a':3, 'b':4}, {'a':5, 'b':6}]

How to make origin to be output as a array

6
  • 1
    Can you not modify origin to be valid JSON? Because that will simplify things immensely. Commented May 12, 2021 at 16:34
  • I am not familiar with JSON. Do you mean to be like this "{'a':1, 'b':2}, {'a':3, 'b':4}, {'a':5, 'b':6}"? Commented May 12, 2021 at 16:36
  • "[{'a':1, 'b':2}, {'a':3, 'b':4}, {'a':5, 'b':6}]" -> '[{"a":1, "b":2}, {"a":3, "b":4}, {"a":5, "b":6}]' the keys have to be in double quotes. Commented May 12, 2021 at 16:38
  • JSON needs double quotes around keys and string values Commented May 12, 2021 at 16:41
  • If it is double quotes, I can use JSON.parse()? Commented May 12, 2021 at 16:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.