Properly marshal JSON error messages.

Fixes the @toekneestuck pointed out.