Ensure --json and --quiet flags work together correctly, outputting only JSON on success and errors only on failure.