0

My json String is

{
"id":"boi12343",
"prompt":
        "{\"sch\":[
                          [\"type\",\"field_name\",\"label\",\"tool_tip\",\"required\",\"default_value\"],
                          [\"Textfield\",\"batch_number\",\"Batch Number\",\"Yea, batch number\",\"Y\",\"123\"],
                          [\"DateField\",\"start_date\",\"Start Date\",\"Start Date\",\"\",\"05\/05\/2014\"]
                  ]
         }",

"contact_info":[
                  ["name","email","phone"],
                  ["John","[email protected]","555555555"]
               ]

}

I can grab id in AngularJS using data.id and data.contact_info[1][0] gives me "John" but how to grab

"Textfield"? I tried data.promt.sch[1][0] but it dosant work

1 Answer 1

1

data.prompt.sch[1][0] doesn't work because the quote marks around the value of the prompt property are backslash escaped. So data.prompt evaluates to a string that contains a JSON data structure.

Try something like this:

JSON.parse(data.prompt).sch[1][0]
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.