JSON commands

We currently send commands as x-www-form-urlencoded. This is no good if we want
commands to have a bit more structure, like having some keys refer to lists. Here we change
that to JSON.