Saturday, 5 November 2022

JavaScript Json Object access by variable name (Without mentioning the actual object name)

let tableFields={1: "bill_date", 2: "amount"};


for(a in res.tableFileds){

let temp=res.tableFileds[a];
html+=`
<div class="divTableCell" style="border:none">`
+res.newRecord[x].data[z][temp]+` </div>
`;}



var data = {"A5A50000":[{"bsid":"A5A50000","chanCount":17,
"time":"2009-05-27 16:36:45","avgInterference":1.711765,"maxInterference":4.97,
"avgHandsets":205.1176,"maxHandsets":315,"avgCalls":6.4118,"maxCalls":13,
"avgCBA":3868.98059,"maxCBA":7463,"sumSuccessCBA":197318,"sumTimeoutHandoff":133,
"sumAttemptHandoff":1028,"sumDeniedHandoff":216,"sumConfirmHandoff":679,
"sumHandoffNetwork":61873,"sumJoinNetwork":96888,"sumLeaveNetwork":93754,
"sumRcvdKeepalive":98773,"sumTimeoutKeepalive":19748,"sumAttemptUplink":93689,
"sumBlockedUplink":62453}]};
var bsID = 'A5A50000';
alert(data[bsID][0].time);

No comments:

Post a Comment

Laravel Export data to csv

 use Illuminate\Http\Response; // Define a function to export data to CSV function exportToCSV($exportData, $columns) {     $filename = ...