1

I am using angular formly to generate some forms. I'm retrieving the form definition from my database, which is multiple json objects. In javascript how to I convert (for example) the following string into an array of objects?

"{"template": "<h2>MAIN HEADING.</h2>"
},
{
    "template": "<h4>sub heading.</h4>"
}"

1 Answer 1

4

Just wrap it in [] so it becomes a JSON array, and then parse it:

var result = JSON.parse( '[' + str + ']' );
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.