Javascript JSON stringify No Numeric Index to include in Data

前端 未结 8 1424
天涯浪人
天涯浪人 2021-01-28 10:52

i am trying to pass non numeric index values through JSON but am not getting the data.

var ConditionArray = new Array();
ConditionArray[0] = \"1\";
ConditionArra         


        
8条回答
  •  甜味超标
    2021-01-28 11:07

    this is the way how I solved this problem Where tblItemsTypeform is array and arrange is de index of the array :

    let itemsData = [];
       
    
        for(var i = 0; i <= this.tblItemsTypeform.length -1;i++){
            let itemsForms = {
                arrange: i,
                values: this.tblItemsTypeform[i]
            }
            itemsData.push(itemsForms)
        }
    

    And finally use this in a variable to send to api:

    var data = JSON.stringify(itemsData)
    

提交回复
热议问题