0

I have a string in Vue JS like

'[{"Request" : {"data":"1,2,3"}}, {"Request" : {"data":"a,b,c"}}]'

I want to have a list with values both with a dict each something like

[{"Request" : {"data":"1,2,3"}}, {"Request" : {"data":"a,b,c"}}]

Basically want to convert string list to actual list

5
  • 3
    JSON.parse()? Commented Oct 5, 2020 at 19:08
  • Hello, JSON.parse() convert json string to json not list. if you see the string its a list and or list of json in string form. trying to convert that Commented Oct 5, 2020 at 19:10
  • the list is JSON JSON only Commented Oct 5, 2020 at 19:14
  • Isnt it a string of list, it starts and ends with '[ ]' so we cant convert to json ? Commented Oct 5, 2020 at 19:17
  • Does this answer your question? Safely turning a JSON string into an object Commented Oct 5, 2020 at 19:18

1 Answer 1

2

You need to use JSON.parse to convert string to JSON

input = '[{"Request" : {"data":"1,2,3"}}, {"Request" : {"data":"a,b,c"}}]'

console.log(JSON.parse(input));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.