Catch exception when parsing an invalid JSON reply

The server *should* always reply with JSON, but don't rely on it.