I got this string output on a page. its HTML and I need to get it "human readable" Its stats from a server.
Could you help me getting it a bit more "clear"
The string printed is:
{"result": ["9.7 - CN", "0", "483;0;0", "483", "0;0;0", "off", "50;20", "45550", "0;0;0;0"]}
Is it possible to get it to be:
Version: 9.7 - CN Speed: 483 Temp/fan 50 20
and so on, any help is appreciated
This must be done client side
I now have this in a html file:
<!DOCTYPE html>
<html>
<body>
<script>
const regex = /{.*}/g;
var request = new XMLHttpRequest();
request.open('GET', 'http://10.0.0.20:3333', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var resp = request.responseText;
var json = regex.exec(resp);
obj = JSON.parse(json[0]);
document.getElementById('content').innerHTML = 'Version: ' + obj.result[0] + '
Speed: ' + obj.result[2].split(';')[0] + ' Temp/fan ' + obj.result[6].replace(';', ' ');
} else {
console.log('We reached our target server, but it returned an error');
}
};
request.onerror = function() {
console.log('There was a connection error of some sort');
};
request.send();
</script>
<div id="content"></div>
</body>
</html>