The JSON-stat viewer won't work on non-ONS JSON-stat responses. The problem seems to be generated by the fixGeocount function. Couldn't the line
jsonstat2 = fixGeocount(jsonstat);
be removed (jsonstat2 is never used), or at least conditionally executed only when the output comes from ONS?
The ONS JSON-stat Viewer would gain in scope, as it could be used on ONS outputs and non-ONS outputs.