Optionally return stats as JSON.