I am working currently on javascript project. In my project i have two json array like:
var one = [{
"dps": {
"1516624200": 0.03333333333333333,
"1516624800": 0.88,
"1516625400": 0.0,
"1516626000": 0.0,
"1516626600": 0.0,
"1516627200": -0.012962962962963048,
"1516627800": -0.022390572390572364,
"1516628400": 20.37605723905724,
"1516629000": 80.06746296296296,
"1516629600": 94.12977777777778,
"1516630200": 94.11733333333332,
"1516630800": 94.1302777777778,
"1516631400": 94.19999999999995
}
}]
var two = [{
"dps": {
"1516624200": 0.2,
"1516624800": 0.95,
"1516625400": 0.0,
"1516626000": 0.0,
"1516626600": 0.0,
"1516627200": -0.55,
"1516627800": -0.6,
"1516628400": 20.77,
"1516629000": 8296296296,
"1516629600": 99,
"1516630200": 99,
"1516630800": 55,
"1516631400": 94.19999999999995
}
}]
I want to merge these two array and finaloutput should be like these type of array
[1516624200,0.03333333333333333,0.2],[1516624800,0.88,0.0]
I am using like:
var graphData = [];
var getValue = data[0].dps;
var getVal = data[1].dps;
for(var i in getVal){
for(j in getVal){
graphData.push([new Date(i*1000),getVal[i],getVal[i]])
}
}
This give me wrong values. Please help.
JSONis a string not an object. If you want to make a JSON String to an object you have to callJSON.parse(myJSONstring)