Hi, I'm trying to get the data from an array of json objects and save them in a different javascript array
For examples I get this JSON through an api rest
[
{
"temperatura": 2.3,
"fecha": "2018-02-05T06:13:01.000Z"
},
{
"temperatura": 2.3,
"fecha": "2018-02-05T06:50:45.000Z"
},
{
"temperatura": 2.3,
"fecha": "2018-02-05T06:52:14.000Z"
},
{
"temperatura": 29,
"fecha": "2018-02-05T06:59:37.000Z"
},
{
"temperatura": 30,
"fecha": "2018-02-05T07:19:36.000Z"
}
]
I would like to be able to save the temperatures in one array and the dates in another different array
I wanted to do this
$(document).ready(function () {
var processed_json = new Array();
var fechas = new Array();
$.getJSON('https://secure-brushlands-10563.herokuapp.com/sensors/temperaturas', function (json) {
// Populate series
console.log(json);
for (i = 0; i < 11; i++) {
$.each(json[i], function (index, data) {
processed_json.push(data);
});
}
console.log(processed_json);
console.log(typeof(processed_json));
And I get this
Array [ 2.3, "2018-02-05T05:46:29.000Z", 2.3, "2018-02-05T06:13:01.000Z", 2.3, "2018-02-05T06:50:45.000Z", 2.3, "2018-02-05T06:52:14.000Z", 29, "2018-02-05T06:59:37.000Z", … ]
object
Thank you very much