refactor JSON responses

We now use some convenience functions to factor
out code to respond with json with response with
attribute 'ok' signifying whether or not a process
was successful