Read and write commands

We can now read and write the command stream as a JSON object, useful for testing.