rest.py and sse.py should probably use the same `_toJson` function.  Not in this pull req, but something to fix in another..