var json = [{
"key": "Apples",
"value": "4"
}, {
"key": "Pears",
"value": "7"
}, {
"key": "Bananas",
"value": "9"
}];
var processed_json = new Array();
$.map(json, function(obj, i) {
processed_json.push([obj.key, parseInt(obj.value)]);
});
if (processed_json.length != 0) {
loadJson();
}
function loadJson() {
$('#container').highcharts({
chart: {
type: 'column'
},
xAxis: {
type: "category"
},
series: [{
data: processed_json
}]
});
}
function getData() {
const url = 'https://mcapi.ca/query/play.minesuperior.com/info';
const response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
var params = JSON.parse(response.getContentText());
var d = new Date();
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var n =sheet.getRange("A1").getValue()+2;
sheet.getRange("A"+n).setValue(d);
sheet.getRange("B"+n).setValue(params.players.online);
sheet.getRange("A1").setValue(n-1);
}
$json = file_get_contents('https://mcapi.ca/query/play.minesuperior.com/info');
$data = json_decode($json);
$online = $data[0]['players']['online'];
echo $online;
// или запись в файл
file_put_contents('/path/to/my/file.txt', $online);
XMLHttpRequest
/ fetch
/ другая библиотека для запросов.setInterval
делаете каждую минуту запрос к API и выводите полученное значение в нужном месте. И динамическое обновление будет и не надо пинать php
или python
:) from json import loads, dumps
s = '{"foo": "bar"}'
d = loads(s)
print(d)
del d['foo']
print(d)
print( dumps(d) )