Improved interfaces for json encoding.
Added input-error and msg commands.