Javascript remaping array into object the 0 (zero) values are excluded -
I have a problem (another): Repeating the array in the object 0 (zero) values are excluded. Why and how to ignore this price? I need this 0 (zero) value :)
My array:
var data = {"queryInfo": {"totalRows": "18"}, "As a result": [["A", "Maxie", "ACC - GC", "SER", 5646.5], ["A", "Maxy", "ACCA - CA", "Kit", 2474.93], [ "A +", "Maxy", "ACC - DIV", "FORM", 1531.04], ["A +", "A", "ACC", "ACC", "SACC", "Net", 5418.72] , "Maxy", "ACC - DIV", "", "AIC - GC", "TEAM", 435], "A +", "MAXI", "ACC - DIV", "High Tech", 0], ["A +", "Maxy", "ACC - GC" ["A +", "MAXI", "ACC - LPI", "ALYS", 651], ["A +", "MAXI", "ACC - LPI "," F IR ", 0], [" A + "," Maxi "," SCC "," Drum ", 36 9 3,6], [" A + "," Maxi "," SCC "," HEL ", 0 ], ["B", "SCC", "SEC", 48474.06], ["B", "S", "S", "SCC", "Lot", "B", "", "S" , "", "", "", "" "," "", "", "", " "# Null", "# null", 1197.6], ["# null", "max i", "# null", "# null", 2940], ["# null", "# null" "Cold index": ["Cold index": 0, "calltype": "string", "call name": "cp"}, {"cold index", "# null", "# null", 2372]], "metadata" : 1, "CallType": "string", "callname": "ST" "ColIntype": "ColIndex": 3, "ColType": "String", "ColName": "PR"}, {"colInndex"}, {"Cold index": 2, "calltype": "string", " : 4, "colType": "numeric", "colName": "VALUE"}]}; and my functions:
function, rickom (as a result) {var obj = {}; For (var j = 0; j & lt; resultset.length; j ++) {if (resultet [j]) {obj [data.metadata [j] .colName] = resultset [j]; }} Return obj; } Var arr = []; (Var i = 0; i & lt; data.resultset.length; i ++) {if (data.resultset [i]! == faucet) {arr.push (recom (data.resultset [i]) ); }} This function takes each metadata and is added as the key in the next final array. As you can see in this, the result should be: {"CP": "A +", "ST": "MAXI", "GR": "SCC", "PR": " DRUM "," VALUE ": 3693.36} , but when the 4th index of dataettset is 0 (zero), my function does not return anything at that level: {" CP ":" A The correct result is: {"CP": "A +", "ST": "SC", "SRC": "SCC", "PR": "HEL"} 0 value due to the result from index "VALUE" "SEC", "PR": "HEL", "value": 0}
Is missing To work from.
Thank you.
your < Pre> if (resultset [j])
/ Pre>
try it:
if (Resultset [j] === 0 | resultset [j])
Comments
Post a Comment