Question - How do I convert JSON data into objects? You can find the JSON data here
Details - After successfully connecting to the API and retrieving the JSON data, I am looking to map two arrays data.hourly.time[]
and data.hourly.temperature_2m[]
into a single DataTable
. I require the DataTable to display the JSON data using the Google Charts API
. Below is an example of the DataTable format I am aiming to create using the two arrays from the JSON data.
Javascript Code
$.ajax({
url: FullURL,
dataType: "JSON",
success: function (data) {
alert(data.hourly.time[1] + "_" + data.hourly.temperature_2m[1]);
// The example below is from the Google API documentation. I aim to convert the JSON array into a DataTable
var data = new google.visualization.DataTable();
data.addColumn('number', 'X');
data.addColumn('number', 'Dogs');
data.addRows([
[0, 0], [1, 10], [2, 23], [3, 17], [4, 18], [5, 9],
[6, 11], [7, 27], [8, 33], [9, 40], [10, 32], [11, 35],
[12, 30], [13, 40], [14, 42], [15, 47], [16, 44], [17, 48],
[18, 52], [19, 54], [20, 42], [21, 55], [22, 56], [23, 57],
[24, 60], [25, 50], [26, 52], [27, 51], [28, 49], [29, 53]
]);