Iterate Json Data in JavaScript/TypeScript

后端 未结 2 1343
感情败类
感情败类 2021-01-19 15:00

I need to Iterate on this Json Data and add value to the Grid in JavaScript(TypeScript) No Jquery.

{\"GridHeader\":{\"Id\":\"Id\",\"Name\":\"Full Name\",\"Ag         


        
2条回答
  •  被撕碎了的回忆
    2021-01-19 15:40

    Yes, your data is actually a javascript object below:

    var header = {
        "GridHeader":{"Id":"Id","Name":"Full Name","Age":"Age"},
      "GridData":   {"Id":3,"name":"Vu","age":34}
      };
    

    And you can loop through it like below:

    for (var prop in header) {
            console.log("Key:" + prop);
            console.log("Value:" + header[prop]);
        }
    

    Please, make it according to your needs. I have give you a clue to iterate it. Thanks.

提交回复
热议问题