seld/jsonlint
seld/jsonlint is a PHP JSON parser/linter that provides clear, line-based parse error messages. Lint or parse JSON with exceptions, detect or collect duplicate keys, parse to assoc arrays, and optionally allow comments—ideal for validating user-edited JSON.
composer require seld/jsonlint.use Seld\JsonLint\JsonParser; and instantiate the parser.lint() for quick validation (returns null if valid or a ParsingException with detailed diagnostics).json_decode() but with better error context), use parse().vendor/bin/jsonlint config.json directly after install — no custom code needed for basic file linting.json_decode($json) === false to detect failure, then fall back to $parser->lint() or $parser->parse() to surface precise error messages to users. This preserves performance while maintaining usability (as Composer does internally).JsonParser::DETECT_KEY_CONFLICTS to throw DuplicateKeyException, then extract line/key info via $e->getDetails().ALLOW_COMMENTS for dev-focused configs (e.g., config.dev.json with // or /* */ comments), but avoid in production for strict JSON compliance.PARSE_TO_ASSOC when returning parsed data to templates or APIs expecting arrays over stdClass objects.parse() as a drop-in json_decode() replacement. It is significantly slower—only invoke it when validation or rich error reporting is needed.-q for quiet mode (e.g., in CI) to avoid polluting logs.parse() in try/catch for external/untrusted inputs.| (e.g., PARSE_TO_ASSOC | ALLOW_COMMENTS). Ensure no flags conflict (though defaults are non-overlapping).lint(), call getMessage() for developer-facing errors and getDetails() for programmatic context (line/column/key). In CLI, the output is already colorized and human-optimized—great for CI or pre-commit hooks.How can I help you explore Laravel packages today?