Support building JSON messages in code.

A few changes to make messages writable so you can construct JSON requests in code.