You mean something like this:
This filters only state events and parses the data (and puts it in a table). I think you indeed need to use the jsonparser
<!DOCTYPE html>
<html>
<head>
<style> table, td {border: 1px solid black;} </style>
</head>
<body>
<h1>Getting Openhab server updates</h1>
<div id="result"></div>
<table id="myTable">
<tr>
<th>Topic</th>
<th>Value</th>
<th>Type</th>
<th>Payload</th>
</tr>
</table>
<br>
<script>
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("http://192.168.3.50:8080/rest/events?topics=smarthome/items/ReigerPowerAbsWd/state");
source.onmessage = function(eventPayload) {
<!--document.getElementById("result").innerHTML += eventPayload.data + "<br>"; -->
var event = JSON.parse(eventPayload.data);
if (event.type == "ItemStateEvent") {
var stateData = JSON.parse(event.payload);
var table = document.getElementById("myTable");
var row = table.insertRow(1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML = event.topic;
cell2.innerHTML = stateData.value;
cell3.innerHTML = event.type;
cell4.innerHTML = event.payload;
};
};
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>
</body>
</html>