Error cases should output valid json too.