Accessing JSON data

后端 未结 4 493
轮回少年
轮回少年 2020-12-12 01:17

If I am given the following data by a web-service:

{
    \"d\": [
        {
            \"col1\": \"col 1 data 1\",
            \"col2\": \"col 2 data 1\"
           


        
4条回答
  •  春和景丽
    2020-12-12 01:46

    Its an array with 2 elements containing col1 and col2, so something like:

    alert(data.d[1].col1);
    

    (0 is the first element, and then you choose "col1")

提交回复
热议问题