1

i have a string

[{"id":"en-Us","name":"English"},{"id":"fr-FR","name":"French"}]  

i want to convert it into

[{id:"en-Us",name:"English"},{id:"fr-FR",name:"French"}]    

using javascript or jquery. Is there any way to convert it this format, for prepoluated autocomplete

1 Answer 1

2

You can use JSON.parse(string) to convert a valid JSON string to a JSON object.

Try,

var xStr = '[{"id":"en-Us","name":"English"},{"id":"fr-FR","name":"French"}]'

var xObj = JSON.parse(xStr);
Sign up to request clarification or add additional context in comments.

1 Comment

The quotes should probably changed.

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.