How to convert object containing Objects into array of objects

前端 未结 7 1528
忘了有多久
忘了有多久 2020-11-29 04:41

This is my Object

var data = {
    a:{\"0\": \"1\"},
    b:{\"1\": \"2\"},
    c:{\"2\": \"3\"},
    d:{\"3\": \"4\"}
};

This is the output

7条回答
  •  借酒劲吻你
    2020-11-29 05:31

    I get what you want ! Here is your solution,

    var dataObject=[{name:'SrNo',type:'number'}];
    

    And to access or store the array use

    dataObject[0].srno=1;
    dataObject[0].srno=2;
    

    Hope this is what you needed.

提交回复
热议问题